<?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>boedesign - canadian based web developer eh</title>
	<atom:link href="http://boedesign.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://boedesign.com</link>
	<description>The dabbling of various web technologies by Jordan Boesch</description>
	<lastBuildDate>Thu, 11 Mar 2010 01:55:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Delegate and Undelegate in jQuery 1.4.2</title>
		<link>http://boedesign.com/blog/2010/03/05/using-delegate-and-undelegate-in-jquery-1-4-2/</link>
		<comments>http://boedesign.com/blog/2010/03/05/using-delegate-and-undelegate-in-jquery-1-4-2/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 14:13:51 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[index]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=618</guid>
		<description><![CDATA[View the article at http://www.learningjquery.com/2010/03/using-delegate-and-undelegate-in-jquery-1-4-2
]]></description>
			<content:encoded><![CDATA[<p>View the article at <a href="http://www.learningjquery.com/2010/03/using-delegate-and-undelegate-in-jquery-1-4-2">http://www.learningjquery.com/2010/03/using-delegate-and-undelegate-in-jquery-1-4-2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2010/03/05/using-delegate-and-undelegate-in-jquery-1-4-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hijacking JavaScript/jQuery methods</title>
		<link>http://boedesign.com/blog/2010/02/13/hijacking-javascriptjquery-methods/</link>
		<comments>http://boedesign.com/blog/2010/02/13/hijacking-javascriptjquery-methods/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 17:13:05 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[index]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=586</guid>
		<description><![CDATA[Some people often wonder: &#8220;Hey, when a user calls $(&#8217;body&#8217;).css(&#8217;background&#8217;, &#8217;something-awesome&#8217;); is there a way I can run some code before that happens?&#8221;.  The answer is yes and it&#8217;s not very hard to do.  If there is a name for this technique, I&#8217;m not aware of it so I&#8217;m just going to call [...]]]></description>
			<content:encoded><![CDATA[<p>Some people often wonder: &#8220;Hey, when a user calls $(&#8217;body&#8217;).css(&#8217;background&#8217;, &#8217;something-awesome&#8217;); is there a way I can run some code before that happens?&#8221;.  The answer is yes and it&#8217;s not very hard to do.  If there is a name for this technique, I&#8217;m not aware of it so I&#8217;m just going to call it &#8220;hijacking&#8221;.</p>
<p><strong>UPDATE:</strong> I have an expanded version of this technique.  It includes a destroy() method to restore the original function/method.  Check out the <a href="http://gist.github.com/309803">gist on github</a>.</p>
<p>The process would be to create a function that returns the method along with some custom arguments that have been tampered with (scary, I know). Here is something basic to achieve this effect:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">jQuery.<span style="color: #E5FFBE;">fn</span>.<span style="color: #E5FFBE;">css</span> <span style="color: #aaa;01">=</span> <span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>_jQueryCSS<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
	<span style="color: #fff;">return</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color:#494F51;">// Run some custom code here and alter the arguments passed in</span>
		<span style="color: #fff;">return</span> _jQueryCSS.<span style="color: #E5FFBE;">call</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">this</span><span style="color: #aaa;01">,</span> arguments<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#40;</span>jQuery.<span style="color: #E5FFBE;">fn</span>.<span style="color: #E5FFBE;">css</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>This technique has been done before by other developers.  <a href="http://james.padolsey.com/">James Padolsey</a> implements this technique in his <a href="http://github.com/jamespadolsey/jQuery-Plugins/blob/master/cross-domain-ajax/jquery.xdomainajax.js"><em>cross-domain-ajax plugin</em></a> and over-writes the jQuery.ajax method.</p>
<p>Normally I would stay clear of methods under another namespace <em>(Don&#8217;t modify objects you don&#8217;t own -Nicholas Zakas)</em> but sometimes it makes sense to over-write them to add your own custom bits like in James&#8217; case (just be careful <img src='http://boedesign.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> , he&#8217;s not hurting the current functionality of jQuery.ajax, he&#8217;s simply augmenting it. I&#8217;ve created a simple function to handle this type of hijacking.</p>
<h3>The hijack function</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color:#494F51;">/**
* Allows you to alter with arguments before the method is actually called
* @param {Function} method A method/function to call after doing some tampering
* @param {Function} cb A callback that is passed the arguments for you to play with
*/</span>
<span style="color: #fff;">function</span> hijack<span style="color: #E5FFBE;01">&#40;</span>method<span style="color: #aaa;01">,</span> cb<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
	<span style="color:#494F51;">// A function needs to be passed or there will be hell to pay</span>
	<span style="color: #fff;">if</span><span style="color: #E5FFBE;01">&#40;</span>Object.<span style="color: #E5FFBE;">prototype</span>.<span style="color: #E5FFBE;">toString</span>.<span style="color: #E5FFBE;">call</span><span style="color: #E5FFBE;01">&#40;</span>cb<span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">!==</span> <span style="color: #fff;">&quot;[object Function]&quot;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color: #fff;">throw</span> <span style="color: #fff;">new</span> Error<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'An anonymous function must be passed as the second parameter!'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
	<span style="color: #fff;">return</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
		<span style="color:#494F51;">// Turn arguments into a true array</span>
		<span style="color: #fff;">var</span> args <span style="color: #aaa;01">=</span> Array.<span style="color: #E5FFBE;">prototype</span>.<span style="color: #E5FFBE;">slice</span>.<span style="color: #E5FFBE;">call</span><span style="color: #E5FFBE;01">&#40;</span>arguments<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
		<span style="color:#494F51;">// Call the copied method and pass it some 'tampered' arguments from our callback</span>
		<span style="color: #fff;">return</span> method.<span style="color: #E5FFBE;">apply</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">this</span><span style="color: #aaa;01">,</span> cb.<span style="color: #E5FFBE;">call</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">this</span><span style="color: #aaa;01">,</span> args<span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">||</span> args<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span></pre></div></div>

<h3>Usage</h3>
<p>Here is a simple use-case of how you would hijack the CSS method in jQuery.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color:#494F51;">// Hijack the CSS method in jQuery</span>
jQuery.<span style="color: #E5FFBE;">fn</span>.<span style="color: #E5FFBE;">css</span> <span style="color: #aaa;01">=</span> hijack<span style="color: #E5FFBE;01">&#40;</span>jQuery.<span style="color: #E5FFBE;">fn</span>.<span style="color: #E5FFBE;">css</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>user_args<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
	<span style="color:#494F51;">// Now store the arguments passed in by the user</span>
	<span style="color: #fff;">var</span> args <span style="color: #aaa;01">=</span> user_args<span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color:#494F51;">// Do some checking and alter the arguments</span>
	<span style="color: #fff;">if</span><span style="color: #E5FFBE;01">&#40;</span>args<span style="color: #E5FFBE;01">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #E5FFBE;01">&#93;</span> <span style="color: #aaa;01">==</span> <span style="color: #fff;">'background'</span> <span style="color: #aaa;01">&amp;&amp;</span> args<span style="color: #E5FFBE;01">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #E5FFBE;01">&#93;</span> <span style="color: #aaa;01">==</span> <span style="color: #fff;">'this-will-be-replaced-with-green'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		args<span style="color: #E5FFBE;01">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #E5FFBE;01">&#93;</span> <span style="color: #aaa;01">=</span> <span style="color: #fff;">'green'</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
	<span style="color: #fff;">return</span> args<span style="color: #aaa;01">;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>So now when I call:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'body'</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">css</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'background'</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">'this-will-be-replaced-with-green'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>It will run through my hijacked function and replace &#8216;this-will-be-replaced-with-green&#8217; with &#8216;green&#8217;.  And voila, your background is green.</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2010/02/13/hijacking-javascriptjquery-methods/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaScript: Configs for Different Environments</title>
		<link>http://boedesign.com/blog/2010/01/21/javascript-configs/</link>
		<comments>http://boedesign.com/blog/2010/01/21/javascript-configs/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 04:41:49 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[index]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=559</guid>
		<description><![CDATA[When you&#8217;re developing a website, you typically have a development version of the site running locally (localhost), a staging version and a production version.  Normally you would set up something that would automatically grab the necessary settings to use for that specific environment.
Here&#8217;s what my CakePHP&#8217;s config/database.php file looks like (PHP4 unfortunately). You&#8217;ll notice [...]]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re developing a website, you typically have a development version of the site running locally (localhost), a staging version and a production version.  Normally you would set up something that would automatically grab the necessary settings to use for that specific environment.</p>
<p>Here&#8217;s what my <a href="http://cakephp.org">CakePHP&#8217;s</a> config/database.php file looks like (PHP4 unfortunately). You&#8217;ll notice I have a set of options for my development environment ($dev) and one for my production environment ($prod).  You&#8217;ll notice that when <em>new DATABASE_CONFIG()</em> is called, the __contruct method will fire and set $this->default to the appropriate environment that we&#8217;re in.  It does this by checking to see if the domain that we&#8217;re on is the production domain.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color: #E5FFBE;"><span style="color: #fff;">class</span> DATABASE_CONFIG <span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
	<span style="color: #fff;">var</span> <span style="color: #81869F;">$default</span> <span style="color: #aaa;01">=</span> <span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span> <span style="color:#494F51;">// overridden</span>
&nbsp;
	<span style="color:#494F51;">// debugging enabled - development site</span>
	<span style="color: #fff;">var</span> <span style="color: #81869F;">$dev</span> <span style="color: #aaa;01">=</span> <span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span>
		<span style="color: #aaa;">'driver'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'mysql'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'persistent'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'host'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'localhost'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'port'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">''</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'login'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'root'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'password'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'root'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'database'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'polly_pocket'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'schema'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">''</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'prefix'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">''</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'encoding'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">''</span>
	<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color:#494F51;">// debugging disabled - live site</span>
	<span style="color: #fff;">var</span> <span style="color: #81869F;">$prod</span> <span style="color: #aaa;01">=</span> <span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span>
		<span style="color: #aaa;">'driver'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'mysql'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'persistent'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'host'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'localhost'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'port'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">''</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'login'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'root'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'password'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'asodij390284niusofdiuh3823_SUPER_SECURE!!!'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'database'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'polly_pocket'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'schema'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">''</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'prefix'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">''</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'encoding'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">''</span>
	<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color: #fff;">function</span> __construct<span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
		<span style="color: #81869F;">$this</span><span style="color: #aaa;01">-&gt;</span><span style="color: #E5FFBE;">default</span> <span style="color: #aaa;01">=</span> <span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">str_replace</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'www.'</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">''</span><span style="color: #aaa;01">,</span> <span style="color: #81869F;">$_SERVER</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'HTTP_HOST'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">==</span> <span style="color: #aaa;">'prod-live-site.com'</span><span style="color: #E5FFBE;01">&#41;</span> ? <span style="color: #81869F;">$this</span><span style="color: #aaa;01">-&gt;</span><span style="color: #E5FFBE;">prod</span> <span style="color: #aaa;01">:</span> <span style="color: #81869F;">$this</span><span style="color: #aaa;01">-&gt;</span><span style="color: #E5FFBE;">dev</span><span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span></pre></div></div>

<p>I&#8217;m sure there is a simpler way of doing this, maybe merging in the necessary key/values with <em>array_merge</em> instead of re-writing the entire array &#8211; but you get the idea.</p>
<p>Now I want to talk about accomplishing the same sort of idea but with JavaScript.  I recently had to work on a project that was largely front-end.  Different configurations had to be used for different environments. Here is what I came up with:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color:#494F51;">/**
* Fire it up and set options
* @constructor
*/</span>	
<span style="color: #fff;">var</span> SiteName <span style="color: #aaa;01">=</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
	<span style="color:#494F51;">/**
	* We check the config host to load in and over-write the default settings
	* @private
	*/</span>
	<span style="color: #fff;">function</span> setOptions<span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
		<span style="color: #fff;">var</span> clean_host <span style="color: #aaa;01">=</span> <span style="color: #E5FFBE;01">&#40;</span>window.<span style="color: #E5FFBE;">location</span>.<span style="color: #E5FFBE;">hostname</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">replace</span><span style="color: #E5FFBE;01">&#40;</span><span style="color:#494F51;">/www./</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">''</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
		<span style="color: #fff;">if</span><span style="color: #E5FFBE;01">&#40;</span>config<span style="color: #E5FFBE;01">&#91;</span>clean_host<span style="color: #E5FFBE;01">&#93;</span> <span style="color: #aaa;01">&amp;&amp;</span> <span style="color: #fff;">typeof</span><span style="color: #E5FFBE;01">&#40;</span>config<span style="color: #E5FFBE;01">&#91;</span>clean_host<span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">===</span> <span style="color: #fff;">'object'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
			<span style="color: #fff;">this</span>.<span style="color: #E5FFBE;">opts</span> <span style="color: #aaa;01">=</span> jQuery.<span style="color: #E5FFBE;">extend</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#123;</span><span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span> config.<span style="color: #fff;">default</span><span style="color: #aaa;01">,</span> config<span style="color: #E5FFBE;01">&#91;</span>clean_host<span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
		<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
	<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
	<span style="color:#494F51;">/**
	* Here is where we define our default set of options and our options to be merged/over-written with
	* options specific to the host name
	* @private
	*/</span>
	<span style="color: #fff;">var</span> config <span style="color: #aaa;01">=</span> <span style="color: #E5FFBE;01">&#123;</span>
		<span style="color: #fff;">&quot;default&quot;</span> <span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#123;</span>
			cache<span style="color: #aaa;01">:</span> <span style="color: #fff;">true</span><span style="color: #aaa;01">,</span>
			backgroundAnimated<span style="color: #aaa;01">:</span> <span style="color: #fff;">true</span><span style="color: #aaa;01">,</span>
			allowIE6Users<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span>
			blowUpMachineIfIE6User<span style="color: #aaa;01">:</span> <span style="color: #fff;">true</span><span style="color: #aaa;01">,</span>
			storeURL<span style="color: #aaa;01">:</span> <span style="color: #fff;">''</span><span style="color: #aaa;01">,</span>
			blogURL<span style="color: #aaa;01">:</span> <span style="color: #fff;">''</span>
		<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span>
		<span style="color: #fff;">&quot;localhost&quot;</span> <span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#123;</span>
			backgroundAnimated<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span>
			blogURL <span style="color: #aaa;01">:</span> <span style="color: #fff;">&quot;http://localhost/blog&quot;</span><span style="color: #aaa;01">,</span>
			storeURL<span style="color: #aaa;01">:</span> <span style="color: #fff;">&quot;http://localhost/store&quot;</span>
		<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span>
		<span style="color: #fff;">&quot;prod-live.com&quot;</span> <span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#123;</span>
			blogURL <span style="color: #aaa;01">:</span> <span style="color: #fff;">&quot;http://prod-live.com/blog&quot;</span><span style="color: #aaa;01">,</span>
			storeURL <span style="color: #aaa;01">:</span> <span style="color: #fff;">'http://store.prod-live.com/main'</span>
		<span style="color: #E5FFBE;01">&#125;</span>
	<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color:#494F51;">/**
	* Once the configs are merged from setOptions, it puts it in this new clean options object
	* @public
	*/</span>
	<span style="color: #fff;">this</span>.<span style="color: #E5FFBE;">opts</span> <span style="color: #aaa;01">=</span> <span style="color: #E5FFBE;01">&#123;</span><span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">;</span>
&nbsp;
	setOptions.<span style="color: #E5FFBE;">call</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">this</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
<span style="color: #fff;">var</span> MySite <span style="color: #aaa;01">=</span> <span style="color: #fff;">new</span> SiteName<span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
console.<span style="color: #E5FFBE;">log</span><span style="color: #E5FFBE;01">&#40;</span>MySite.<span style="color: #E5FFBE;">opts</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>
All this is doing is running a check to see if the config exists for the domain that we&#8217;re on and if so, merge it with the defaults.  It&#8217;s important to note that this technique uses jQuery&#8217;s <em><a href="http://api.jquery.com/jQuery.extend/">extend</a></em> method. If we are on the <em>localhost</em> domain then our <em>SiteName.opts</em> will look now like this:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color: #E5FFBE;01">&#123;</span> 
	cache<span style="color: #aaa;01">:</span> <span style="color: #fff;">true</span><span style="color: #aaa;01">,</span>
	backgroundAnimated<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span>
	allowIE6Users<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span>
	blowUpMachineIfIE6User<span style="color: #aaa;01">:</span> <span style="color: #fff;">true</span><span style="color: #aaa;01">,</span>
	blogURL <span style="color: #aaa;01">:</span> <span style="color: #fff;">&quot;http://localhost/blog&quot;</span><span style="color: #aaa;01">,</span>
	storeURL<span style="color: #aaa;01">:</span> <span style="color: #fff;">&quot;http://localhost/store&quot;</span>
<span style="color: #E5FFBE;01">&#125;</span></pre></div></div>

<p>I&#8217;m sure storing config in an XML file and parsing it would be a logical approach as well. I&#8217;m open to any suggestions and thoughts on this approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2010/01/21/javascript-configs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keystrokes for jQuery</title>
		<link>http://boedesign.com/blog/2009/12/30/keystrokes-for-jquery/</link>
		<comments>http://boedesign.com/blog/2009/12/30/keystrokes-for-jquery/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 21:34:11 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[lab]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=493</guid>
		<description><![CDATA[Background
First off, I hope everyone had fun over the holidays &#8211; I certainly did! With the release of jQuery 1.4 jQuery 1.4 on the horizon for early in the new year, I decided I wanted to try out some of its new functionality.  I&#8217;ve been reading blogs of some of the jQuery core developers [...]]]></description>
			<content:encoded><![CDATA[<h3>Background</h3>
<p>First off, I hope everyone had fun over the holidays &#8211; I certainly did! With the release of jQuery 1.4 <strike><a href="http://blog.jquery.com/2009/12/18/jquery-14-alpha-2-released/">jQuery 1.4 on the horizon</a> for early in the new year</strike>, I decided I wanted to try out some of its new functionality.  I&#8217;ve been reading blogs of some of the jQuery core developers and I found <a href="http://brandonaaron.net/blog/2009/03/26/special-events">a post by Brandon Aaron</a> to be very interesting.  He talks about adding custom events to jQuery using its special event API.  So I started making my custom event plugin and then realized that you could not bind the event to the same element twice.  Meaning, you can&#8217;t do this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$<span style="color: #E5FFBE;01">&#40;</span>document<span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">bind</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'myevent'</span><span style="color: #aaa;01">,</span> <span style="color: #E5FFBE;01">&#123;</span> data<span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#91;</span><span style="color: #fff;">'some data'</span><span style="color: #E5FFBE;01">&#93;</span> <span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>event<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span> <span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
$<span style="color: #E5FFBE;01">&#40;</span>document<span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">bind</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'myevent'</span><span style="color: #aaa;01">,</span> <span style="color: #E5FFBE;01">&#123;</span> data<span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#91;</span><span style="color: #fff;">'more data'</span><span style="color: #E5FFBE;01">&#93;</span> <span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>event<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span> <span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>
So I tried using namespaces and it still would only fire the first event bind, not the second.  Wow, what a drag.  Then I found that Brandon wrote a <a href="http://brandonaaron.net/blog/2009/06/4/jquery-edge-new-special-event-hooks">new article</a> about two new methods that were added to the custom event hook: <em>add</em> and <em>remove</em> .  They both get fired on an event &#8220;bind&#8221; and &#8220;unbind&#8221; &#8211; perfect!  Uh oh, these two methods are not available in the latest stable release of jQuery (1.3.2).  They are only available in the release of jQuery 1.4!  So yes, unfortunately, <strong>you have to upgrade to <a href="http://jquery.com">jQuery 1.4.2 (or greater)</a></strong> to use this plugin.
</p>
<h3>What is Keystrokes? (Hot keys)</h3>
<p>
Keystrokes is a jQuery plugin that can capture a sequence of keys that are pressed.  It would come in pretty handy if you were doing a web application and wanted to allow the users to use hot keys.   It can even detect combo keys like &#8217;shift+ctrl&#8217;.  It would operate exactly as you type it.  In this case, the user would hold down <em>shift</em>, hit <em>ctrl</em> and the event you specified would fire.</p>
<p>This plugin has been tested in: Firefox 3.5, Safari 4, Opera 10 and IE 7+. It might work in IE 6 but I&#8217;m not promising anything.</p>
<p><a class="linkbutton" href="http://github.com/jboesch/Keystrokes/archives/master">Download It! (v2.0)</a></p>
<p><a class="demobutton" href="/demos/keystrokes">Demo It!</a></p>
<h3>Setting it up</h3>
<p>Make sure these are in the head of your document</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="color: #E5FFBE;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;google.load('jquery','1.4.2');&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.keystrokes.min.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<h3>Adding a basic event</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$<span style="color: #E5FFBE;01">&#40;</span>document<span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">bind</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'keystrokes'</span><span style="color: #aaa;01">,</span> <span style="color: #E5FFBE;01">&#123;</span>
	<span style="color:#494F51;">// The key pattern you set your element to listen for</span>
	keys<span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#91;</span><span style="color: #fff;">'i'</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">'p'</span><span style="color: #E5FFBE;01">&#93;</span>				
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>event<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
	<span style="color:#494F51;">// Throw a notification to the user what keys they successfully typed</span>
	<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'You typed : &lt;em&gt;'</span> <span style="color: #aaa;01">+</span> event.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">stack_item</span>.<span style="color: #E5FFBE;">keys</span>.<span style="color: #E5FFBE;">join</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">', '</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">+</span> <span style="color: #fff;">'&lt;/em&gt;'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>If this is done correctly, when the user hits <em>i</em> then <em>p</em>, you will get an alert notification. See the <a href="/demos/keystrokes">demo page</a> for a full the full effect.</p>
<h3>Adding a basic event that unbinds itself upon successful key strokes</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$<span style="color: #E5FFBE;01">&#40;</span>document<span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">bind</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'keystrokes.SingleItem'</span><span style="color: #aaa;01">,</span> <span style="color: #E5FFBE;01">&#123;</span>
	<span style="color:#494F51;">// The key pattern you set your element to listen for	</span>
	keys<span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#91;</span><span style="color: #fff;">'m'</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">'arrow down+r'</span><span style="color: #E5FFBE;01">&#93;</span>		
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>event<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
	<span style="color:#494F51;">// Unbind this event after it's been successfully typed</span>
	$<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">this</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">unbind</span><span style="color: #E5FFBE;01">&#40;</span>event.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">stack_item</span>.<span style="color: #fff;">name</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'You typed : &lt;em&gt;'</span> <span style="color: #aaa;01">+</span> event.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">stack_item</span>.<span style="color: #E5FFBE;">keys</span>.<span style="color: #E5FFBE;">join</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">', '</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">+</span> <span style="color: #fff;">'&lt;/em&gt;.  You cannot type it again because it has been unbound!'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<h3>Adding a more complex notification that contains multiple key sets</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$<span style="color: #E5FFBE;01">&#40;</span>document<span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">bind</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'keystrokes.OtherNameSpace'</span><span style="color: #aaa;01">,</span> <span style="color: #E5FFBE;01">&#91;</span>		
	<span style="color: #E5FFBE;01">&#123;</span>
		<span style="color:#494F51;">// Define typed keys in sequence</span>
		keys<span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#91;</span><span style="color: #fff;">'h'</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">'shift+p+o'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #aaa;01">,</span>
		<span style="color:#494F51;">// If false, this will not execute the main callback, only the &quot;success&quot; callback on this stack item</span>
		proceedToMainCallback<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span>
		<span style="color:#494F51;">// The callback bound to this specific stack item</span>
		success<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>event<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
			<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'You typed : &lt;em&gt;'</span> <span style="color: #aaa;01">+</span> event.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">stack_item</span>.<span style="color: #E5FFBE;">keys</span>.<span style="color: #E5FFBE;">join</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">', '</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">+</span> <span style="color: #fff;">'&lt;/em&gt;.  This has &quot;proceedToMainCallback: false&quot; so it will not call the main callback for this bound event.&lt;/em&gt;'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
		<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
	<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span>
	<span style="color: #E5FFBE;01">&#123;</span>
		<span style="color:#494F51;">// Define typed keys in sequence</span>
		keys<span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#91;</span><span style="color: #fff;">'j'</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">'k'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #aaa;01">,</span>
		<span style="color:#494F51;">// The callback bound to this specific stack item</span>
		success<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>event<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
			<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'You typed : &lt;em&gt;'</span> <span style="color: #aaa;01">+</span> event.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">stack_item</span>.<span style="color: #E5FFBE;">keys</span>.<span style="color: #E5FFBE;">join</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">', '</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">+</span> <span style="color: #fff;">'&lt;/em&gt;'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
		<span style="color: #E5FFBE;01">&#125;</span>
	<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span>
	<span style="color: #E5FFBE;01">&#123;</span>
		<span style="color:#494F51;">// Define typed keys in sequence</span>
		keys<span style="color: #aaa;01">:</span> <span style="color: #E5FFBE;01">&#91;</span><span style="color: #fff;">'arrow up+comma+k'</span><span style="color: #aaa;01">,</span> <span style="color: #cc66cc;">1</span><span style="color: #aaa;01">,</span> <span style="color: #cc66cc;">2</span><span style="color: #aaa;01">,</span> <span style="color: #cc66cc;">3</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #aaa;01">,</span>
		<span style="color:#494F51;">// The callback bound to this specific stack item</span>
		success<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>event<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
			<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'You typed : &lt;em&gt;'</span> <span style="color: #aaa;01">+</span> event.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">stack_item</span>.<span style="color: #E5FFBE;">keys</span>.<span style="color: #E5FFBE;">join</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">', '</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">+</span> <span style="color: #fff;">'&lt;/em&gt;'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
		<span style="color: #E5FFBE;01">&#125;</span>
	<span style="color: #E5FFBE;01">&#125;</span>			
<span style="color:#494F51;">// The main callback that gets called with every successful key sequence</span>
<span style="color:#494F51;">// This can be skipped by setting 'proceedToMainCallback: false' as an option in a stack item</span>
<span style="color: #E5FFBE;01">&#93;</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>event<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>	
		<span style="color:#494F51;">// Maybe get the whole stack.. if you want?</span>
		<span style="color: #fff;">var</span> stack <span style="color: #aaa;01">=</span> event.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">stack</span><span style="color: #aaa;01">;</span>
		<span style="color:#494F51;">// Get the specific stack item that was successfully typed</span>
		<span style="color: #fff;">var</span> data_keys <span style="color: #aaa;01">=</span> event.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">stack_item</span>.<span style="color: #E5FFBE;">keys</span>.<span style="color: #E5FFBE;">join</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">', '</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
		<span style="color:#494F51;">// Shout it out!</span>
		<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'&lt;span&gt;This is the main callback for selected successful keystrokes. To skip this call, just set &quot;proceedToMainCallback: false&quot; in your stack item: &lt;/span&gt; '</span> <span style="color: #aaa;01">+</span> data_keys<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color: #E5FFBE;01">&#125;</span>
<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<h3>Key set options</h3>
<p>Below is a list of all possible options that go with a key set.</p>
<table>
<thead>
<tr>
<th>Key</th>
<th>Default Value</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>keys</td>
<td>[] (required)</td>
<td>Array</td>
<td>The specified key sequence you wish to listen for.  Example: ['shift+ctrl', 'o', 1, 5, 'space']</td>
</tr>
<tr>
<td>customValidation</td>
<td>null</td>
<td>Function</td>
<td>You can run your own validation and decide whether the user completed the key sequence the way you wanted them to.  See the <a href="/demos/keystrokes">demo</a> for an example.</td>
</tr>
<tr>
<td>success</td>
<td>null</td>
<td>Function</td>
<td>If you are using an array of key sets as seen in the advanced example, you can specify a callback unique to that key set.</td>
</tr>
<tr>
<td>proceedToMainCallback</td>
<td>true</td>
<td>Boolean</td>
<td>If you&#8217;ve specified a &#8217;success&#8217; callback (see above) and you don&#8217;t want to have the main callback executed, set this to false. This is more commonly used in the advanced example.</td>
</tr>
</tbody>
</table>
<h3>String list</h3>
<p>Below is a table of all possible key strings you can enter in your <em>keys</em> array. </p>
<table>
<thead>
<tr>
<th>Key Code</th>
<th>String</th>
</tr>
</thead>
<tbody>
<tr>
<td>8</td>
<td>backspace</td>
</tr>
<tr>
<td>9</td>
<td>tab</td>
</tr>
<tr>
<td>13</td>
<td>enter</td>
</tr>
<tr>
<td>16</td>
<td>shift</td>
</tr>
<tr>
<td>17</td>
<td>ctrl</td>
</tr>
<tr>
<td>18</td>
<td>alt</td>
</tr>
<tr>
<td>19</td>
<td>pause/break</td>
</tr>
<tr>
<td>20</td>
<td>caps lock</td>
</tr>
<tr>
<td>27</td>
<td>escape</td>
</tr>
<tr>
<td>33</td>
<td>page up</td>
</tr>
<tr>
<td>32</td>
<td>space</td>
</tr>
<tr>
<td>34</td>
<td>page down</td>
</tr>
<tr>
<td>35</td>
<td>end</td>
</tr>
<tr>
<td>36</td>
<td>home</td>
</tr>
<tr>
<td>37</td>
<td>arrow left</td>
</tr>
<tr>
<td>38</td>
<td>arrow up</td>
</tr>
<tr>
<td>39</td>
<td>arrow right</td>
</tr>
<tr>
<td>40</td>
<td>arrow down</td>
</tr>
<tr>
<td>44</td>
<td>print screen</td>
</tr>
<tr>
<td>45</td>
<td>insert</td>
</tr>
<tr>
<td>46</td>
<td>delete</td>
</tr>
<tr>
<td>48</td>
<td>0</td>
</tr>
<tr>
<td>49</td>
<td>1</td>
</tr>
<tr>
<td>50</td>
<td>2</td>
</tr>
<tr>
<td>51</td>
<td>3</td>
</tr>
<tr>
<td>52</td>
<td>4</td>
</tr>
<tr>
<td>53</td>
<td>5</td>
</tr>
<tr>
<td>54</td>
<td>6</td>
</tr>
<tr>
<td>55</td>
<td>7</td>
</tr>
<tr>
<td>56</td>
<td>8</td>
</tr>
<tr>
<td>57</td>
<td>9</td>
</tr>
<tr>
<td>59</td>
<td>semi-colon</td>
</tr>
<tr>
<td>61</td>
<td>add</td>
</tr>
<tr>
<td>65</td>
<td>a</td>
</tr>
<tr>
<td>66</td>
<td>b</td>
</tr>
<tr>
<td>67</td>
<td>c</td>
</tr>
<tr>
<td>68</td>
<td>d</td>
</tr>
<tr>
<td>69</td>
<td>e</td>
</tr>
<tr>
<td>70</td>
<td>f</td>
</tr>
<tr>
<td>71</td>
<td>g</td>
</tr>
<tr>
<td>72</td>
<td>h</td>
</tr>
<tr>
<td>73</td>
<td>i</td>
</tr>
<tr>
<td>74</td>
<td>j</td>
</tr>
<tr>
<td>75</td>
<td>k</td>
</tr>
<tr>
<td>76</td>
<td>l</td>
</tr>
<tr>
<td>77</td>
<td>m</td>
</tr>
<tr>
<td>78</td>
<td>n</td>
</tr>
<tr>
<td>79</td>
<td>o</td>
</tr>
<tr>
<td>80</td>
<td>p</td>
</tr>
<tr>
<td>81</td>
<td>q</td>
</tr>
<tr>
<td>82</td>
<td>r</td>
</tr>
<tr>
<td>83</td>
<td>s</td>
</tr>
<tr>
<td>84</td>
<td>t</td>
</tr>
<tr>
<td>85</td>
<td>u</td>
</tr>
<tr>
<td>86</td>
<td>v</td>
</tr>
<tr>
<td>87</td>
<td>w</td>
</tr>
<tr>
<td>88</td>
<td>x</td>
</tr>
<tr>
<td>89</td>
<td>y</td>
</tr>
<tr>
<td>90</td>
<td>z</td>
</tr>
<tr>
<td>91</td>
<td>left window key</td>
</tr>
<tr>
<td>92</td>
<td>right window key</td>
</tr>
<tr>
<td>93</td>
<td>select key</td>
</tr>
<tr>
<td>96</td>
<td>numpad 0</td>
</tr>
<tr>
<td>97</td>
<td>numpad 1</td>
</tr>
<tr>
<td>98</td>
<td>numpad 2</td>
</tr>
<tr>
<td>99</td>
<td>numpad 3</td>
</tr>
<tr>
<td>100</td>
<td>numpad 4</td>
</tr>
<tr>
<td>101</td>
<td>numpad 5</td>
</tr>
<tr>
<td>102</td>
<td>numpad 6</td>
</tr>
<tr>
<td>103</td>
<td>numpad 7</td>
</tr>
<tr>
<td>104</td>
<td>numpad 8</td>
</tr>
<tr>
<td>105</td>
<td>numpad 9</td>
</tr>
<tr>
<td>106</td>
<td>multiply</td>
</tr>
<tr>
<td>107</td>
<td>add</td>
</tr>
<tr>
<td>109</td>
<td>subtract</td>
</tr>
<tr>
<td>110</td>
<td>decimal point</td>
</tr>
<tr>
<td>111</td>
<td>divide</td>
</tr>
<tr>
<td>112</td>
<td>f1</td>
</tr>
<tr>
<td>113</td>
<td>f2</td>
</tr>
<tr>
<td>114</td>
<td>f3</td>
</tr>
<tr>
<td>115</td>
<td>f4</td>
</tr>
<tr>
<td>116</td>
<td>f5</td>
</tr>
<tr>
<td>117</td>
<td>f6</td>
</tr>
<tr>
<td>118</td>
<td>f7</td>
</tr>
<tr>
<td>119</td>
<td>f8</td>
</tr>
<tr>
<td>120</td>
<td>f9</td>
</tr>
<tr>
<td>121</td>
<td>f10</td>
</tr>
<tr>
<td>122</td>
<td>f11</td>
</tr>
<tr>
<td>123</td>
<td>f12</td>
</tr>
<tr>
<td>144</td>
<td>num lock</td>
</tr>
<tr>
<td>145</td>
<td>scroll lock</td>
</tr>
<tr>
<td>182</td>
<td>my computer (multimedia keyboard)</td>
</tr>
<tr>
<td>183</td>
<td>my calculator (multimedia keyboard)</td>
</tr>
<tr>
<td>186</td>
<td>semi-colon</td>
</tr>
<tr>
<td>187</td>
<td>equal sign</td>
</tr>
<tr>
<td>188</td>
<td>comma</td>
</tr>
<tr>
<td>189</td>
<td>dash</td>
</tr>
<tr>
<td>190</td>
<td>period</td>
</tr>
<tr>
<td>191</td>
<td>forward slash</td>
</tr>
<tr>
<td>192</td>
<td>tilde</td>
</tr>
<tr>
<td>219</td>
<td>open bracket</td>
</tr>
<tr>
<td>220</td>
<td>back slash</td>
</tr>
<tr>
<td>221</td>
<td>close bracket</td>
</tr>
<tr>
<td>222</td>
<td>single quote</td>
</tr>
<tr>
<td>224</td>
<td>command</td>
</tr>
</tbody>
</table>
<p>You can also add/modify to the string list by adding this line above your event calls:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color:#494F51;">// Simply supply the key code and the string you wish to use.</span>
$.<span style="color: #E5FFBE;">extend</span><span style="color: #E5FFBE;01">&#40;</span>$.<span style="color: #E5FFBE;">event</span>.<span style="color: #E5FFBE;">special</span>.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">codes</span><span style="color: #aaa;01">,</span> <span style="color: #E5FFBE;01">&#123;</span> <span style="color: #cc66cc;">13</span> <span style="color: #aaa;01">:</span> <span style="color: #fff;">'my enter key'</span> <span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>If you have something like Firebug and you want to do some debugging, you can add this line above your event calls:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$.<span style="color: #E5FFBE;">event</span>.<span style="color: #E5FFBE;">special</span>.<span style="color: #E5FFBE;">keystrokes</span>.<span style="color: #E5FFBE;">debug</span> <span style="color: #aaa;01">=</span> <span style="color: #fff;">true</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>
Now, if you open up your console, you will be able to see what keys the script thinks you&#8217;re typing. If you hit a key that&#8217;s not registered in our string list, it will output that key code to the console and notify you.  This makes it easy for you to do your own customizations.
</p>
<p>By default, Keystrokes ignores when you&#8217;re typing keys in any input/textarea field.  If you want to track keys on an input field you have to bind it directly to that input element.</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2009/12/30/keystrokes-for-jquery/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Dissecting jQuery.noConflict</title>
		<link>http://boedesign.com/blog/2009/12/07/dissecting-jquery-noconflict/</link>
		<comments>http://boedesign.com/blog/2009/12/07/dissecting-jquery-noconflict/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 07:57:33 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[index]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=455</guid>
		<description><![CDATA[Most jQuery users love it for its easy CSS selectors, DOM manipulation and slick effects.  We don&#8217;t normally think about what happens behind the scenes when we call our favorite jQuery methods, we just naturally expect they work as desired. 

I&#8217;m going to start off my dissecting and explaining a relatively simple method called [...]]]></description>
			<content:encoded><![CDATA[<p>Most jQuery users love it for its easy CSS selectors, DOM manipulation and slick effects.  We don&#8217;t normally think about what happens behind the scenes when we call our favorite jQuery methods, we just naturally expect they work as desired. </p>
<p>
I&#8217;m going to start off my dissecting and explaining a relatively simple method called <em>noConflict</em>. If you want to follow along you can download a <a href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.js&#038;downloadBtn=">development copy of jQuery</a>.  As of this post, we&#8217;re using version 1.3.2.
</p>
<p>Open up the file and go to line 19.  You&#8217;ll see the code below</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color:#494F51;">// Map over jQuery in case of overwrite</span>
_jQuery <span style="color: #aaa;01">=</span> window.<span style="color: #E5FFBE;">jQuery</span><span style="color: #aaa;01">,</span>
<span style="color:#494F51;">// Map over the $ in case of overwrite</span>
_$ <span style="color: #aaa;01">=</span> window.$<span style="color: #aaa;01">,</span>
&nbsp;
jQuery <span style="color: #aaa;01">=</span> window.<span style="color: #E5FFBE;">jQuery</span> <span style="color: #aaa;01">=</span> window.$ <span style="color: #aaa;01">=</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span> selector<span style="color: #aaa;01">,</span> context <span style="color: #E5FFBE;01">&#41;</span> <span style="color: #E5FFBE;01">&#123;</span>
	<span style="color:#494F51;">// The jQuery object is actually just the init constructor 'enhanced'</span>
	<span style="color: #fff;">return</span> <span style="color: #fff;">new</span> jQuery.<span style="color: #E5FFBE;">fn</span>.<span style="color: #E5FFBE;">init</span><span style="color: #E5FFBE;01">&#40;</span> selector<span style="color: #aaa;01">,</span> context <span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span></pre></div></div>

<p>Right away you&#8217;ll notice that 2 variables are created with an underscore, this is to hold a reference to the old namespaces that might be in use.  For example, if we load the Prototype JavaScript framework before jQuery, it uses the $ function, so jQuery makes a copy of that reference before it over writes it with it&#8217;s own below.  Now if we ever want to get back to the Prototype $ reference, we can get at it with the _$ variable.</p>
<p>Note:  If you load the jQuery library before Prototype, there is no need to call <em>noConflict()</em>. But you will have to set up a new way to target elements &#8211; see below.</p>
<p>This now brings us to the <em>noConflict</em> method.  If you go to line 619 you&#8217;ll see our lovely method:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">noConflict<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span> deep <span style="color: #E5FFBE;01">&#41;</span> <span style="color: #E5FFBE;01">&#123;</span>
	window.$ <span style="color: #aaa;01">=</span> _$<span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color: #fff;">if</span> <span style="color: #E5FFBE;01">&#40;</span> deep <span style="color: #E5FFBE;01">&#41;</span>
		window.<span style="color: #E5FFBE;">jQuery</span> <span style="color: #aaa;01">=</span> _jQuery<span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color: #fff;">return</span> jQuery<span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span></pre></div></div>

<p>Remember that _$ variable that get&#8217;s set at the top of the jQuery file?  There it is!  If you remember, we copied an existing $ reference (Prototype) into the _$ variable to get at it later if we wanted.  In this method we return the $ sign to it&#8217;s owner, which in this case is the Prototype $ function. It&#8217;s set by the line that says <em>window.$ = _$</em>. We use the <em>window</em> prefix to reference the global namespace.  Now we want our $ function back so we can use it for Prototype, you can do this by calling the <em>noConflict()</em> method:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">jQuery.<span style="color: #E5FFBE;">noConflict</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
$<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'someid'</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">hide</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span> <span style="color:#494F51;">// The $ function is now using Prototype to target elements</span>
jQuery<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'#someid'</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">hide</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color:#494F51;">// The jQuery function is used instead of the $ function</span></pre></div></div>

<p>But I hate typing jQuery each time I target some elements, what can I do? Simple.  Since the <em>noConflict()</em> method returns the jQuery object, we can store that in a variable.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color: #fff;">var</span> jQ <span style="color: #aaa;01">=</span> jQuery.<span style="color: #E5FFBE;">noConflict</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
$<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'someid'</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">hide</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span> <span style="color:#494F51;">// The $ function is now using Prototype to target elements</span>
jQ<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'#someid'</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">hide</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color:#494F51;">// The jQ function after we set it above</span></pre></div></div>

<p>
 The <em>noConflict()</em> method also accepts one boolean parameter called <em>deep</em>.  For the most part, this does not need to be set unless you&#8217;re working in a high conflict environment.  For example, you might have 2 versions of jQuery running or something else using the jQuery namespace (god I hope not).  That might be grounds for setting the <em>deep</em> parameter to true. For example you could move the jQuery object to an entirely new namespace:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color: #aaa;01">&lt;</span>script type<span style="color: #aaa;01">=</span><span style="color: #fff;">&quot;text/javascript&quot;</span> src<span style="color: #aaa;01">=</span><span style="color: #fff;">&quot;js/jquery-1.3.1.js&quot;</span><span style="color: #aaa;01">&gt;&lt;/</span>script<span style="color: #aaa;01">&gt;</span>
<span style="color: #aaa;01">&lt;</span>script type<span style="color: #aaa;01">=</span><span style="color: #fff;">&quot;text/javascript&quot;</span> src<span style="color: #aaa;01">=</span><span style="color: #fff;">&quot;js/prototype.js&quot;</span><span style="color: #aaa;01">&gt;&lt;/</span>script<span style="color: #aaa;01">&gt;</span>
<span style="color: #aaa;01">&lt;</span>script type<span style="color: #aaa;01">=</span><span style="color: #fff;">&quot;text/javascript&quot;</span> src<span style="color: #aaa;01">=</span><span style="color: #fff;">&quot;js/jquery-1.3.2.js&quot;</span><span style="color: #aaa;01">&gt;&lt;/</span>script<span style="color: #aaa;01">&gt;</span>
<span style="color: #fff;">var</span> myNamespace <span style="color: #aaa;01">=</span> <span style="color: #E5FFBE;01">&#123;</span><span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">;</span>
myNamespace.<span style="color: #E5FFBE;">query</span> <span style="color: #aaa;01">=</span> jQuery.<span style="color: #E5FFBE;">noConflict</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">true</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
myNamespace.<span style="color: #E5FFBE;">query</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'#my-id-with-new-version-of-jquery'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span> <span style="color:#494F51;">// This will execute using jQuery 1.3.2</span>
jQuery<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'#my-id-with-old-version-of-jquery'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span> <span style="color:#494F51;">// This will execute using jQuery 1.3.1</span>
$<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'my-id-with-prototype'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span> <span style="color:#494F51;">// This will execute using Prototype</span></pre></div></div>

<p><a href="/sandbox/noconflict.html">View the the demo</a> I made of <em>jQuery.noConflict(true)</em> in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2009/12/07/dissecting-jquery-noconflict/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Serverside JavaScript Minifying</title>
		<link>http://boedesign.com/blog/2009/12/02/serverside-javascript-minifying/</link>
		<comments>http://boedesign.com/blog/2009/12/02/serverside-javascript-minifying/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 10:52:20 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[index]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=429</guid>
		<description><![CDATA[JSMIN is a JavaScript minifying library that was founded by Douglas Crockford.  Minifying is the act of taking your JavaScript code and stripping out unneeded white space and comments to reduce file size.  Douglas Crockford offers a set of packages in common server side languages to accomplish this &#8211; whether it be PHP, [...]]]></description>
			<content:encoded><![CDATA[<p>JSMIN is a JavaScript minifying library that was founded by <a href="http://www.crockford.com/javascript/jsmin.html">Douglas Crockford</a>.  Minifying is the act of taking your JavaScript code and stripping out unneeded white space and comments to reduce file size.  Douglas Crockford offers a set of packages in common server side languages to accomplish this &#8211; whether it be <a href="http://code.google.com/p/jsmin-php/">PHP</a>, <a href="http://www.crockford.com/javascript/jsmin.py.txt">Python</a> or <a href="http://inconspicuous.org/projects/jsmin/jsmin.java">Java</a>.  It&#8217;s important to note that <a href="http://developer.yahoo.com/yui/compressor/">there</a> <a href="http://www.askapache.com/online-tools/js-compress/">are</a> <a href="http://code.google.com/closure/compiler/">other</a> JavaScript compression and compiling tools out there,  I am just giving an example of one that I use frequently.</p>
<p>I&#8217;m going to show you what I&#8217;ve done with the PHP package of JSMIN.  </p>
<p>If you download the <a href="http://code.google.com/p/jsmin-php/">PHP package</a> you&#8217;ll see how to use is simple:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color: #E5FFBE;"><span style="color: #aaa; font-weight: bold;">&lt;?</span>
<span style="color: #fff;">require</span> <span style="color: #aaa;">'jsmin-1.1.1.php'</span><span style="color: #aaa;01">;</span>
<span style="color: #fff;">echo</span> JSMin<span style="color: #aaa;01">::</span><span style="color: #E5FFBE;">minify</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">file_get_contents</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'example.js'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #aaa; font-weight: bold;">?&gt;</span></pre></div></div>

<p>
Brilliant!  It will output a bunch of ugly code right?  Well who cares if it&#8217;s ugly, it&#8217;s only for production.  What I wanted to do with this is have something that takes multiple JavaScript files, minifies them and then outputs it to 1 JavaScript file that&#8217;s all tightly bundled.  Here&#8217;s how to do that.
</p>
<p>First, you&#8217;ll want to make sure that the jsmin-1.1.1.php class is included.  Then write a function to handle the minifying of multiple JavaScript files.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color: #E5FFBE;"><span style="color: #aaa; font-weight: bold;">&lt;?</span>
<span style="color:#494F51;">/********************************************
* Handle an array of JavaScript files, minify them and output them into 1 file.
* @param string $final_file The path to the final JavaScript file that will contain all minified contents
* @param array $js_files The array of JavaScript files to minify
* @return string The script tag including the path to the final JavaScript file
*/</span>
<span style="color: #fff;">function</span> drawMinJS<span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$final_file</span><span style="color: #aaa;01">,</span> <span style="color: #81869F;">$js_files</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
	<span style="color: #81869F;">$contents</span> <span style="color: #aaa;01">=</span> <span style="color: #aaa;">''</span><span style="color: #aaa;01">;</span>
	<span style="color: #fff;">foreach</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$js_files</span> <span style="color: #fff;">as</span> <span style="color: #81869F;">$src</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color:#494F51;">// We use a semicolon at the end to safely separate the files</span>
		<span style="color: #81869F;">$contents</span> <span style="color: #aaa;01">.=</span> JSMin<span style="color: #aaa;01">::</span><span style="color: #E5FFBE;">minify</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">file_get_contents</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$src</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span> <span style="color: #aaa;01">.</span> <span style="color: #aaa;">';'</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span>
	<span style="color: #81869F;">$str</span> <span style="color: #aaa;01">=</span> <span style="color: #aaa;">'&lt;script type=&quot;text/javascript&quot; src=&quot;'</span> <span style="color: #aaa;01">.</span> <span style="color: #81869F;">$final_file</span> <span style="color: #aaa;01">.</span> <span style="color: #aaa;">'&quot;&gt;&lt;/script&gt;'</span><span style="color: #aaa;01">;</span>
	file_put_contents<span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$final_file</span><span style="color: #aaa;01">,</span> <span style="color: #81869F;">$contents</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
	<span style="color: #fff;">return</span> <span style="color: #81869F;">$str</span><span style="color: #aaa;01">;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span>
<span style="color: #aaa; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Then put the snippet below where ever you would like the script tag to appear.  Sometimes people put it in the &lt;head&gt; of the document and sometimes right before the &lt;/body&gt;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color: #E5FFBE;"><span style="color: #aaa; font-weight: bold;">&lt;?</span>
<span style="color:#494F51;">// Not to worry, this outputs the actual &lt;script&gt; tag</span>
<span style="color: #fff;">echo</span> drawMinJS<span style="color: #E5FFBE;01">&#40;</span>
	<span style="color: #aaa;">'js/finalfile.min.js'</span><span style="color: #aaa;01">,</span>
	<span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span>
		<span style="color: #aaa;">'js/global.js'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'js/thickbox.js'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'js/twitter.js'</span><span style="color: #aaa;01">,</span>
		<span style="color: #aaa;">'js/events.js'</span>
	<span style="color: #E5FFBE;01">&#41;</span>
<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #aaa; font-weight: bold;">?&gt;</span></pre></div></div>

<p>
Voila! The function will take all those JavaScript files in that array, minify them and put them into finalfile.min.js.<br />
I also recommend reading &#8220;<a href="http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/">The best way to load external JavaScript</a>&#8221; by Nicholas C. Zakas if you&#8217;re looking for more ways to improve performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2009/12/02/serverside-javascript-minifying/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>yayQuery &#8211; A jQuery Podcast</title>
		<link>http://boedesign.com/blog/2009/11/20/yayquery-a-jquery-podcast/</link>
		<comments>http://boedesign.com/blog/2009/11/20/yayquery-a-jquery-podcast/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 09:02:01 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[index]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=420</guid>
		<description><![CDATA[yayQuery is a jQuery podcast that cleverly starts at episode 0,  they discuss a whole lot about javascript tools, plugins, anti-patterns and performance.  It&#8217;s a jQuery podcast of 4 solid front-end developers: Paul Irish, Rebecca Murphey, Alex Sexton and Adam J. Sontag.
You can visit the website to watch episodes or follow them on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://yayquery.com">yayQuery</a> is a jQuery podcast that cleverly starts at episode 0,  they discuss a whole lot about javascript tools, plugins, anti-patterns and performance.  It&#8217;s a jQuery podcast of 4 solid front-end developers: <a href="http://paulirish.com">Paul Irish</a>, <a href="http://www.rebeccamurphey.com/">Rebecca Murphey</a>, <a href="http://alexsexton.com/">Alex Sexton</a> and <a href="http://www.ajpiano.com/">Adam J. Sontag</a>.</p>
<p>You can visit the <a href="http://yayquery.com">website</a> to watch episodes or follow them on <a href="http://twitter.com/yayquery">twitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2009/11/20/yayquery-a-jquery-podcast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jSquares for jQuery</title>
		<link>http://boedesign.com/blog/2009/10/22/jsquares-for-jquery/</link>
		<comments>http://boedesign.com/blog/2009/10/22/jsquares-for-jquery/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 12:00:40 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[lab]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=398</guid>
		<description><![CDATA[If you&#8217;ve viewed my &#8220;lab&#8221; section, that is a perfect example of what this is.  jSquares is a jQuery plugin that pops up an image and a description in an overlay on hover.  It is basically identical to the image grid found on www.ted.com.  Works like a charm in IE6+, FF 3+, [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve viewed my &#8220;lab&#8221; section, that is a perfect example of what this is.  jSquares is a jQuery plugin that pops up an image and a description in an overlay on hover.  It is basically identical to the image grid found on <a href="http://www.ted.com/">www.ted.com</a>.  Works like a charm in IE6+, FF 3+, Safari 3+ and Opera 10.</p>
<p><a class="linkbutton" href="http://github.com/jboesch/jSquares/archives/master">Download It! (v1.2)</a></p>
<p><a class="demobutton" href="/demos/jsquares">Demo It!</a></p>
<p><strong>Setting it up</strong></p>
<p>Make sure you&#8217;re including these files in the head of your document</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="html" style="color: #E5FFBE;">&lt;script src=&quot;http://www.google.com/jsapi&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;google.load(&quot;jquery&quot;,&quot;1.3.2&quot;);&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;css/jsquares.css&quot; type=&quot;text/css&quot; media=&quot;all&quot; /&gt;
&lt;script src=&quot;js/jquery.jsquares.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></div></div>

</p>
<p>To initiate jSquares simply wrap it in the jQuerys document ready function like so.</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color: #aaa;01">&lt;</span>script type<span style="color: #aaa;01">=</span><span style="color: #fff;">&quot;text/javascript&quot;</span><span style="color: #aaa;01">&gt;</span>
$<span style="color: #E5FFBE;01">&#40;</span>document<span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">ready</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
	$<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'#js-container'</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">jsquares</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #aaa;01">&lt;/</span>script<span style="color: #aaa;01">&gt;</span></pre></div></div>

</p>
<p>The default chunk of HTML will look something like this:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="html" style="color: #E5FFBE;">&lt;div id=&quot;js-container&quot;&gt;	
	&lt;div class=&quot;js-image&quot;&gt;		
		&lt;a href=&quot;#wolf!&quot;&gt;&lt;img class=&quot;js-small-image&quot; src=&quot;images/wolf-moon.jpg&quot;/&gt;&lt;/a&gt;
		&lt;div class=&quot;js-small-caption&quot;&gt;
			&lt;span&gt;Howlla at cha boy!&lt;/span&gt;
		&lt;/div&gt;
		&lt;div class=&quot;js-overlay-caption-content&quot;&gt;
			&lt;h4&gt;You can't hide from wolf boy.&lt;/h4&gt;
			&lt;p&gt;
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. In elementum arcu non orci fermentum nec suscipit neque dignissim... &lt;a href=&quot;#&quot;&gt;Read more &amp;raquo;&lt;/a&gt;
			&lt;/p&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre></div></div>

</p>
<p><strong>Optional parameters</strong></p>
<p>Parameters can be added when you call jsquares like so:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'#js-container'</span><span style="color: #E5FFBE;01">&#41;</span>.<span style="color: #E5FFBE;">jsquares</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#123;</span> 
	shuffle_in<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span> <span style="color:#494F51;">// have the pictures all fade in on page load?</span>
	fade_on_hover<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span> <span style="color:#494F51;">// do we want the images to fade on hover or just change opacity?</span>
	caption_slide_down<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span> <span style="color:#494F51;">// do we want the caption to slide down or just appear?</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

</p>
<p>Here&#8217;s a list of all of the options it can take:</p>
<table>
<thead>
<tr>
<th>Key</th>
<th>Default Value</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>image</td>
<td>.js-image</td>
<td>String</td>
<td>The target element holding all of the info (image/caption).  View the source of the demo for a better understanding.</td>
</tr>
<tr>
<td>caption</td>
<td>.js-small-caption</td>
<td>String</td>
<td>The target element holding the caption.  This element is found within the element specified as <em>js_image</em>.</td>
<tr>
<td>caption_overlay_spacing</td>
<td>12</td>
<td>Integer</td>
<td>This is the padding on the caption that pops up on hover.</td>
<tr>
<td>caption_width</td>
<td>400</td>
<td>Integer</td>
<td>This is the width of the caption that pops up on hover.</td>
</tr>
<tr>
<td>caption_height</td>
<td>130</td>
<td>Integer</td>
<td>This is the height of the caption that pops up on hover.</td>
</tr>
<tr>
<td>fade_to</td>
<td>.3</td>
<td>Integer | Float</td>
<td>This is the opacity that you want the images/captions to fade to when you roll over an image.</td>
<tr>
<td>fade_start</td>
<td>1</td>
<td>Integer | Float</td>
<td>This is opacity that images/captions are sent back to after you roll off the image set.  This normally shouldn&#8217;t be altered.</td>
</tr>
<tr>
<td>shuffle_in</td>
<td>true</td>
<td>Boolean</td>
<td>By default the images will shuffle in (fade in) randomly.  If you don&#8217;t want any effects and to have them just appear, change this to false.</td>
</tr>
<tr>
<td>shuffle_in_speed</td>
<td>130</td>
<td>Integer</td>
<td>If <em>js_shuffle_in</em> is set to true, you can set the speed in which images appear one after the other.</td>
</tr>
<tr>
<td>fade_on_hover</td>
<td>true</td>
<td>Boolean</td>
<td>By default the images fade to a value set by <em>js_fade_to</em>, if you just want them to change opacity then change this to false.</td>
</tr>
<tr>
<td>caption_slide_down</td>
<td>true</td>
<td>Boolean</td>
<td>The caption has a slide down effect when you hover over an image.  If you just want it to appear instead of sliding down, change this to false.</td>
</tr>
<tr>
<td>caption_slidedown_speed</td>
<td>fast</td>
<td>String | Integer</td>
<td>If the option key <em>js_caption_slide_down</em> is set to true, you can change the speed that it slides down at.</td>
</tr>
</tbody>
</table>
<p>Any comments/suggestions are definitely encouraged. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2009/10/22/jsquares-for-jquery/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Auto-activate widgets in WordPress MU</title>
		<link>http://boedesign.com/blog/2009/08/15/auto-activate-widgets-in-wordpress-mu/</link>
		<comments>http://boedesign.com/blog/2009/08/15/auto-activate-widgets-in-wordpress-mu/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 16:45:36 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=341</guid>
		<description><![CDATA[I was recently involved in a project where it was required that each time you add a new blog on WordPress MU, that it automatically assigns a set of default widgets and activates all the plugins.  Finding a plugin that activates all plugins on blog creation was easy, there&#8217;s one out there called Plugin [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently involved in a project where it was required that each time you add a new blog on WordPress MU, that it automatically assigns a set of default widgets and activates all the plugins.  Finding a plugin that activates all plugins on blog creation was easy, there&#8217;s one out there called <a href="http://firestats.cc/wiki/WPMUPluginCommander" target="_blank">Plugin Commander</a> and it&#8217;s awesome &#8211; you can also mass activate and deactivate plugins on all your blogs.</p>
<p><span id="more-341"></span></p>
<p>
After some googling for a widget activation plugin I came across <a href="http://mu.wordpress.org/forums/topic/8041" target="_blank">this forum</a>.  The people seemed to know the hooks and calls to activate widgets but of course I ran into problems &#8211; mainly with widget ids.
</p>
<p>
Here is the code I had in my theme/functions.php file:
</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color: #E5FFBE;"><span style="color:#494F51;">// Can we register sidebars?  Hopefully!</span>
<span style="color: #fff;">if</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">function_exists</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'register_sidebar'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
        <span style="color:#494F51;">// Give your sidebar a unique id and a name, the name will display in the WP control panel</span>
        register_sidebar<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'id'</span> <span style="color: #aaa;01">=&gt;</span><span style="color: #aaa;">'my-sidebar'</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">'name'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'My Sidebar'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span>
<span style="color:#494F51;">// We'll want to assign widgets to the sidebar</span>
<span style="color: #fff;">if</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">function_exists</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'register_sidebar_widget'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
        <span style="color:#494F51;">// Give your widget a name and provide a callback function</span>
        register_sidebar_widget<span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'My Calendar'</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">'widget_my_calendar'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span>
<span style="color:#494F51;">// Our callback from the calendar widget above</span>
<span style="color: #fff;">function</span> widget_my_calendar<span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
        <span style="color: #fff;">echo</span> <span style="color: #aaa;">'&lt;h2&gt;This is my calendar widget being outputted to sidebar.php&lt;/h2&gt;'</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span></pre></div></div>

<p>
Then I found out that to automatically register these widgets to a sidebar on blog creation, that you need to know their unique widget id.  I then had a peek in the database in &#8220;wp_options&#8221;, browsed by &#8220;option_name&#8221; and found  &#8220;widget_my-calendar&#8221;.  WordPress automatically generated a slug for me based on my widget title &#8220;My Calendar&#8221;.  Now I was kind of iffy about that since it&#8217;s obviously better to provide your widget with an id, that way you know how to target it automatically via WordPress&#8217; built-in &#8220;update_option&#8221; function.
</p>
<p>
I did some quick searching through the WordPress core files and saw where it was generating the slug.  I had then seen that it returns an generated slug (id) along with params from &#8220;register_sidebar_widget&#8221; to &#8220;<a href="http://codex.wordpress.org/Function_Reference/wp_register_sidebar_widget" target="_blank">wp_register_sidebar_widget</a>&#8220;&#8230; DUH!  So the wp_register_sidebar_widget function actually lets you pass your id as the first parameter &#8211; awesome.
</p>
<p>
<strong>Enough of my blabbering &#8211; here&#8217;s the plugin I came up with for auto-activating widgets:</strong>
</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color: #E5FFBE;"><span style="color:#494F51;">// Put this in wp-content/mu-plugins/auto-widget-activate.php</span>
<span style="color:#494F51;">/*
Plugin Name: Auto-assign widgets to blog
Version: 1.0
Plugin URI: http://boedesign.com/2009/08/15/auto-activate-widgets-in-wordpress-mu
Author: Jordan Boesch
Author URI: http://boedesign.com
Description: When you create a new blog on MU, have it automatically assign widgets.
*/</span>
&nbsp;
<span style="color: #fff;">define</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'WIDGET_INFO'</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">serialize</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span>
    <span style="color: #aaa;">'sidebar'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'id'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'my-sidebar'</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">'name'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #aaa;">'My Sidebar'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">,</span>
    <span style="color: #aaa;">'widgets'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span>
        <span style="color: #aaa;">'my-subscribe'</span><span style="color: #aaa;01">,</span>
        <span style="color: #aaa;">'my-search'</span><span style="color: #aaa;01">,</span>
        <span style="color: #aaa;">'my-calendar'</span><span style="color: #aaa;01">,</span>
        <span style="color: #aaa;">'my-poll'</span><span style="color: #aaa;01">,</span>
        <span style="color: #aaa;">'my-recent-comments'</span><span style="color: #aaa;01">,</span>
        <span style="color: #aaa;">'my-more-blogs'</span><span style="color: #aaa;01">,</span>
        <span style="color: #aaa;">'my-categories'</span>
    <span style="color: #E5FFBE;01">&#41;</span>
<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
<span style="color:#494F51;">// Everytime you create a new blog, enable all the widgets.</span>
<span style="color: #fff;">function</span> add_default_widgets<span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$blog_id</span><span style="color: #E5FFBE;01">&#41;</span>  <span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
    <span style="color: #81869F;">$widget_info</span> <span style="color: #aaa;01">=</span> <span style="color: #fff;">unserialize</span><span style="color: #E5FFBE;01">&#40;</span>WIDGET_INFO<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
    <span style="color:#494F51;">// We are simply putting the widgets into the table when a blog is created</span>
    <span style="color: #fff;">foreach</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$widget_info</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'widgets'</span><span style="color: #E5FFBE;01">&#93;</span> <span style="color: #fff;">as</span> <span style="color: #81869F;">$widget_id</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
        update_option<span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'widget_'</span> <span style="color: #aaa;01">.</span> <span style="color: #81869F;">$widget_id</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
    <span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
    <span style="color:#494F51;">// Tell what sidebar to have what widgets</span>
    update_option<span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'sidebars_widgets'</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$widget_info</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'sidebar'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'id'</span><span style="color: #E5FFBE;01">&#93;</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #81869F;">$widget_info</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'widgets'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
    <span style="color: #fff;">return</span><span style="color: #aaa;01">;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
<span style="color:#494F51;">// Call the populate_options action on blog creation</span>
add_action<span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'populate_options'</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">'add_default_widgets'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>
Now that you&#8217;ve inserted them into the database on blog creation, you need to provide their callbacks and output.<br />
Put the following code in the functions.php file (theme directory).
</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color: #E5FFBE;"><span style="color:#494F51;">// All widget info is set in wp-content/mu-plugins/assign_widgets.php</span>
<span style="color: #81869F;">$widget_info</span> <span style="color: #aaa;01">=</span> <span style="color: #fff;">unserialize</span><span style="color: #E5FFBE;01">&#40;</span>WIDGET_INFO<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
&nbsp;
<span style="color:#494F51;">// This needs to be called to tell WP that we want to use widgets for this theme</span>
<span style="color: #fff;">if</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">function_exists</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'register_sidebar'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
   register_sidebar<span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">array</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'id'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #81869F;">$widget_info</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'sidebar'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'id'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">'name'</span> <span style="color: #aaa;01">=&gt;</span> <span style="color: #81869F;">$widget_info</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'sidebar'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'name'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
<span style="color:#494F51;">// Our own custom widgets with callbacks</span>
<span style="color: #fff;">if</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">function_exists</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'wp_register_sidebar_widget'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
&nbsp;
    <span style="color: #fff;">foreach</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$widget_info</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'widgets'</span><span style="color: #E5FFBE;01">&#93;</span> <span style="color: #fff;">as</span> <span style="color: #81869F;">$widget_id</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
        <span style="color:#494F51;">// first param is our widget id, second param is a humanized version of the widget id (My Calendar) and the third param is the function that we call to display the widget</span>
        wp_register_sidebar_widget<span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$widget_id</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">ucwords</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">str_replace</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'-'</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">' '</span><span style="color: #aaa;01">,</span> <span style="color: #81869F;">$widget_id</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">'widget_'</span> <span style="color: #aaa;01">.</span> <span style="color: #fff;">str_replace</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #aaa;">'-'</span><span style="color: #aaa;01">,</span> <span style="color: #aaa;">'_'</span><span style="color: #aaa;01">,</span> <span style="color: #81869F;">$widget_id</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
    <span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
<span style="color:#494F51;">// Now you need to create a function for each widget that you assigned in that array, remember &quot;my-calendar&quot;, &quot;my-subscribe&quot; etc?  Those functions will look like this now:</span>
<span style="color: #fff;">function</span> widget_my_calendar<span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
        <span style="color: #fff;">echo</span> <span style="color: #aaa;">&quot;&lt;h2&gt;I'm a calendar widget!&lt;/h2&gt;&quot;</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span>
&nbsp;
<span style="color: #fff;">function</span> widget_my_subscribe<span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
        <span style="color: #fff;">echo</span> <span style="color: #aaa;">&quot;&lt;h2&gt;I'm a subscribe widget!&lt;/h2&gt;&quot;</span><span style="color: #aaa;01">;</span>
<span style="color: #E5FFBE;01">&#125;</span></pre></div></div>

<p>
Now put this code in sidebar.php (theme directory) to call your sidebar.
</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color: #E5FFBE;">dynamic_sidebar<span style="color: #E5FFBE;01">&#40;</span><span style="color: #81869F;">$widget_info</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'sidebar'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#91;</span><span style="color: #aaa;">'id'</span><span style="color: #E5FFBE;01">&#93;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

<p>Happy Mu-ing!</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2009/08/15/auto-activate-widgets-in-wordpress-mu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Gritter for jQuery (Growl)</title>
		<link>http://boedesign.com/blog/2009/07/11/growl-for-jquery-gritter/</link>
		<comments>http://boedesign.com/blog/2009/07/11/growl-for-jquery-gritter/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 23:09:37 +0000</pubDate>
		<dc:creator>Jordan Boesch</dc:creator>
				<category><![CDATA[index]]></category>
		<category><![CDATA[lab]]></category>

		<guid isPermaLink="false">http://boedesign.com/?p=302</guid>
		<description><![CDATA[I&#8217;ve been hunting for a good jQuery Growl look-a-like plugin for some time, but I just can&#8217;t seem to find one that looks the exact same as the one for Mac OS, so like most web dabblers would do, I decided to roll my own.


For those who don&#8217;t know what Growl is, it&#8217;s basically a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hunting for a good jQuery <a href="http://growl.info/images/SmokeScreenshot.png" target="_blank">Growl</a> look-a-like plugin for some time, but I just can&#8217;t seem to find one that looks the exact same as the one for Mac OS, so like most web dabblers would do, I decided to roll my own.
</p>
<p><span id="more-302"></span></p>
<p>For those who don&#8217;t know what Growl is, it&#8217;s basically a notification bubble/popup that appears in the top right of your desktop &#8211; examples can be found <a href="http://growl.info/screenshots.php" target="_blank">here</a>.  Think of it as calling the alert() function in JavaScript, only it&#8217;s not a modal, it&#8217;s subtle and it doesn&#8217;t look like dog shit.</p>
<p><a class="linkbutton" href="http://github.com/jboesch/Gritter/archives/master">Download It! (v1.6)</a></p>
<p><a class="demobutton" href="/demos/gritter">Demo It!</a></p>
<p>
The example above is also included in the download</p>
<p>Note: If you&#8217;re wanting to know how to integrate Gritter with <a href="http://cakephp.org">CakePHP</a> as a flash message, read <a href="http://racotecnic.underave.net/2009/11/implementar-plugin-jquery-de-advertencias-tipo-growl-en-cakephp/">this article.</a> It&#8217;s in Spanish, I know, but if you&#8217;re slightly familiar with CakePHP, the code is what really matters.</p>
<h4>Usage</h4>
<p>First, make sure the folder structure is in place (images/js/css).</p>
<p>Now add this to the head of your document:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/gritter.css&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
<span style="color: #aaa;01">&lt;</span>script type<span style="color: #aaa;01">=</span><span style="color: #fff;">&quot;text/javascript&quot;</span><span style="color: #aaa;01">&gt;</span>google.<span style="color: #E5FFBE;">load</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'jquery'</span><span style="color: #aaa;01">,</span> <span style="color: #fff;">'1.3.2'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;&lt;/</span>script<span style="color: #aaa;01">&gt;</span>
&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.gritter.js&quot;&gt;&lt;/script&gt;</pre></div></div>

</p>
<p><strong>Adding a simple notification</strong></p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$.<span style="color: #E5FFBE;">gritter</span>.<span style="color: #E5FFBE;">add</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#123;</span>
	<span style="color:#494F51;">// (string | mandatory) the heading of the notification</span>
	title<span style="color: #aaa;01">:</span> <span style="color: #fff;">'This is a notice!'</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (string | mandatory) the text inside the notification</span>
	text<span style="color: #aaa;01">:</span> <span style="color: #fff;">'This will fade out after a certain amount of time.'</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

</p>
<p><strong>Adding a more complex notification</strong></p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$.<span style="color: #E5FFBE;">gritter</span>.<span style="color: #E5FFBE;">add</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#123;</span>
	<span style="color:#494F51;">// (string | mandatory) the heading of the notification</span>
	title<span style="color: #aaa;01">:</span> <span style="color: #fff;">'This is a regular notice!'</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (string | mandatory) the text inside the notification</span>
	text<span style="color: #aaa;01">:</span> <span style="color: #fff;">'This will fade out after a certain amount of time.'</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (string | optional) the image to display on the left</span>
	image<span style="color: #aaa;01">:</span> <span style="color: #fff;">'http://a0.twimg.com/profile_images/59268975/jquery_avatar_bigger.png'</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (bool | optional) if you want it to fade out on its own or just sit there</span>
	sticky<span style="color: #aaa;01">:</span> <span style="color: #fff;">false</span><span style="color: #aaa;01">,</span> 
	<span style="color:#494F51;">// (int | optional) the time you want it to be alive for before fading out (milliseconds)</span>
	time<span style="color: #aaa;01">:</span> <span style="color: #cc66cc;">8000</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (string | optional) the class name you want to apply directly to the notification for custom styling</span>
	class_name<span style="color: #aaa;01">:</span> <span style="color: #fff;">'my-class'</span><span style="color: #aaa;01">,</span>
        <span style="color:#494F51;">// (function | optional) function called before it opens</span>
	before_open<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'I am a sticky called before it opens'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (function | optional) function called after it opens</span>
	after_open<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>e<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">&quot;I am a sticky called after it opens: <span style="color: #ccc;">\n</span>I am passed the jQuery object for the created Gritter element...<span style="color: #ccc;">\n</span>&quot;</span> <span style="color: #aaa;01">+</span> e<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (function | optional) function called before it closes</span>
	before_close<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>e<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">&quot;I am a sticky called before it closes: I am passed the jQuery object for the Gritter element... <span style="color: #ccc;">\n</span>&quot;</span> <span style="color: #aaa;01">+</span> e<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (function | optional) function called after it closes</span>
	after_close<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'I am a sticky called after it closes'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

</p>
<p>If you wanted to use the &#8220;sticky: true&#8221; option but still be able to delete it later, you can create a variable that will hold a unique identifier.</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;"><span style="color: #fff;">var</span> unique_id <span style="color: #aaa;01">=</span> $.<span style="color: #E5FFBE;">gritter</span>.<span style="color: #E5FFBE;">add</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#123;</span>
	<span style="color:#494F51;">// (string | mandatory) the heading of the notification</span>
	title<span style="color: #aaa;01">:</span> <span style="color: #fff;">'This is a sticky notice!'</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (string | mandatory) the text inside the notification</span>
	text<span style="color: #aaa;01">:</span> <span style="color: #fff;">'This will not go away until the user has hit the (x) button because sticky has been set to true.'</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (string | optional) the image to display on the left</span>
	image<span style="color: #aaa;01">:</span> <span style="color: #fff;">'http://a0.twimg.com/profile_images/59268975/jquery_avatar_bigger.png'</span><span style="color: #aaa;01">,</span>
	<span style="color:#494F51;">// (bool | optional) if you want it to fade out on its own or just sit there</span>
	sticky<span style="color: #aaa;01">:</span> <span style="color: #fff;">true</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

</p>
<p>Now to delete that specific notification you can call:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$.<span style="color: #E5FFBE;">gritter</span>.<span style="color: #E5FFBE;">remove</span><span style="color: #E5FFBE;01">&#40;</span>unique_id<span style="color: #aaa;01">,</span> <span style="color: #E5FFBE;01">&#123;</span> 
	fade<span style="color: #aaa;01">:</span> <span style="color: #fff;">true</span><span style="color: #aaa;01">,</span> <span style="color:#494F51;">// optional</span>
	speed<span style="color: #aaa;01">:</span> <span style="color: #fff;">'fast'</span> <span style="color:#494F51;">// optional</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

</p>
<p>To remove all Gritter notifications you can call:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$.<span style="color: #E5FFBE;">gritter</span>.<span style="color: #E5FFBE;">removeAll</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

</p>
<p>As well as </p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$.<span style="color: #E5FFBE;">gritter</span>.<span style="color: #E5FFBE;">removeAll</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#123;</span>
        before_close<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span>e<span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">&quot;I am called before all notifications are closed.  I am passed the jQuery object containing all  of Gritter notifications.<span style="color: #ccc;">\n</span>&quot;</span> <span style="color: #aaa;01">+</span> e<span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span><span style="color: #aaa;01">,</span>
	after_close<span style="color: #aaa;01">:</span> <span style="color: #fff;">function</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #E5FFBE;01">&#123;</span>
		<span style="color: #fff;">alert</span><span style="color: #E5FFBE;01">&#40;</span><span style="color: #fff;">'I am called after everything has been closed.'</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span>
	<span style="color: #E5FFBE;01">&#125;</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>

</p>
<p><strong>If you want you can setup global defaults (optional)</strong></p>
<p>Setting up global defaults is handy if you don&#8217;t want to specify a &#8216;time&#8217; attribute for each $.gritter.add call.</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="javascript" style="color: #E5FFBE;">$.<span style="color: #E5FFBE;">extend</span><span style="color: #E5FFBE;01">&#40;</span>$.<span style="color: #E5FFBE;">gritter</span>.<span style="color: #E5FFBE;">options</span><span style="color: #aaa;01">,</span> <span style="color: #E5FFBE;01">&#123;</span> 
	fade_in_speed<span style="color: #aaa;01">:</span> <span style="color: #fff;">'medium'</span><span style="color: #aaa;01">,</span> <span style="color:#494F51;">// how fast notifications fade in (string or int)</span>
	fade_out_speed<span style="color: #aaa;01">:</span> <span style="color: #cc66cc;">2000</span><span style="color: #aaa;01">,</span> <span style="color:#494F51;">// how fast the notices fade out</span>
	time<span style="color: #aaa;01">:</span> <span style="color: #cc66cc;">6000</span> <span style="color:#494F51;">// hang on the screen for...</span>
<span style="color: #E5FFBE;01">&#125;</span><span style="color: #E5FFBE;01">&#41;</span><span style="color: #aaa;01">;</span></pre></div></div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://boedesign.com/blog/2009/07/11/growl-for-jquery-gritter/feed/</wfw:commentRss>
		<slash:comments>101</slash:comments>
		</item>
	</channel>
</rss>
