<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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" version="2.0">

<channel>
	<title>The Bungee Blog</title>
	
	<link>http://www.thebungeebook.net</link>
	<description>News, updates and rants around The Bungee Book (the landmark book on Prototype and script.aculo.us)</description>
	<pubDate>Tue, 16 Sep 2008 12:49:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/bungeebook" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="bungeebook" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>My @mediaAjax 2008 slides</title>
		<link>http://www.thebungeebook.net/2008/09/16/my-mediaajax-2008-slides/</link>
		<comments>http://www.thebungeebook.net/2008/09/16/my-mediaajax-2008-slides/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 12:49:08 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Conferences &amp; workshops]]></category>

		<category><![CDATA[Cool tricks]]></category>

		<category><![CDATA[conference ajax slides slideshow mediaajax @mediaajax]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=46</guid>
		<description><![CDATA[Hi all,

I know, I know.  I&#8217;ve been neglecting that blog far too long.  But with the 2nd edition of my French book to write, the Paris Web conference to organize (and its online registration app to code), @mediaAjax London to prep and the upcoming The Ajax Experience in Boston, plus half a dozen [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>

<p>I know, I know.  I&#8217;ve been neglecting that blog far too long.  But with the 2nd edition of my French book to write, the Paris Web conference to organize (and its online registration app to code), @mediaAjax London to prep and the upcoming The Ajax Experience in Boston, plus half a dozen launches at work, things are pretty tight these days.</p>

<p>I haven&#8217;t given up on this!  I do plan to post more neuron workouts and JS nuggets soon.</p>

<p>in the meantime, I put my slides and related sources for @mediaAjax London 2008 online.  You can <a href="http://tddsworld.com/confs/mediaajax08/">grab it all here</a>, and there&#8217;s a link to the Slideshare page, too.</p>

<p>I hope you enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/09/16/my-mediaajax-2008-slides/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Japanese readers: ようこそ！</title>
		<link>http://www.thebungeebook.net/2008/09/03/japanese-readers-welcome/</link>
		<comments>http://www.thebungeebook.net/2008/09/03/japanese-readers-welcome/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 06:47:53 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=45</guid>
		<description><![CDATA[I&#8217;ve just been notified the Japanese translation of The Bungee Book made it out to shelves on July 28. It&#8217;s wonderful to see the reach of the book broaden like that.  And the cover is rather cool, too:



I also hear Chinese and Korean editions should hit the shelves pretty soon.  Let&#8217;s keep our [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been notified the Japanese translation of The Bungee Book made it out to shelves on July 28. It&#8217;s wonderful to see the reach of the book broaden like that.  And the cover is rather cool, too:</p>

<p><img src="http://thebungeebook.net/TBB_Cover_Japan.jpg" alt="Japanese edition cover" /></p>

<p>I also hear Chinese and Korean editions should hit the shelves pretty soon.  Let&#8217;s keep our fingers crossed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/09/03/japanese-readers-welcome/feed/</wfw:commentRss>
		</item>
		<item>
		<title>First Prototype Developer Day: Monday September 29, 2008!</title>
		<link>http://www.thebungeebook.net/2008/07/25/first-prototype-developer-day-monday-september-29-2008/</link>
		<comments>http://www.thebungeebook.net/2008/07/25/first-prototype-developer-day-monday-september-29-2008/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 16:50:51 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Conferences &amp; workshops]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=44</guid>
		<description><![CDATA[

(cross-posted from the official Prototype blog)

Prototype Core is happy to announce the first Prototype Developer Day!  The Prototype Developer Day is going to be a recurring event bringing together Prototype Core members and users from the Prototype community to share experiences, offer insight into what&#8217;s coming up, and discuss topics like contribution, support, and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/pdd75.gif" style="float: left; margin: 0 10px 10px 0; border: 0;" /></p>

<p><em>(cross-posted from <a href="http://prototypejs.org/2008/7/25/first-prototype-developer-day-monday-september-29-2008">the official Prototype blog</a>)</em></p>

<p>Prototype Core is happy to announce the first Prototype Developer Day!  The Prototype Developer Day is going to be a recurring event bringing together Prototype Core members and users from the Prototype community to share experiences, offer insight into what&#8217;s coming up, and discuss topics like contribution, support, and the Prototype ecosystem.  If you&#8217;re big on Prototype, you cannot miss this!</p>

<p><span id="more-44"></span></p>

<p>This fall, the Prototype Developer Day is being held in conjunction with <a href="http://ajaxexperience.techtarget.com">The Ajax Experience</a>, held in Boston from Monday, September 29 to Wednesday, October 1 2008.  The Prototype Developer Day itself will happen on Monday.</p>

<p><strong>Admission to the Developer Day is free</strong>. If you’re interested in attending the full three days of The Ajax Experience, you can <strong>save $100 with the code <code>Prototype</code></strong>. Register before August 22nd and <strong>save an additional $100</strong>.</p>

<p>The provisional agenda for this Prototype Developer Day is as follows (more details coming up on the <a href="http://ajaxexperience.techtarget.com/east/html/eventsataglance.html?Offer=AEprot717">full agenda</a>):</p>

<p><style type="text/css">#pddAgenda { border: 2px solid silver; border-collapse: collapse; margin: 1em auto; } #pddAgenda th, #pddAgenda td { border: 1px solid silver; text-align: center; padding: 0.2em 0.5em } #pddAgenda th { background: silver; }</style></p>

<table id="pddAgenda">
<thead>
  <tr><th>Start time</th><th>End time</th><th>Session</th><th>Speaker</th></tr>
</thead>
<tbody>
  <tr><td>8:00am</td><td>8:30am</td><td>Intro/Welcome</td><td>Prototype Core</td></tr>
  <tr><td>8:30am</td><td>9:30am</td><td>Contributing docs</td><td>Christophe Porteneuve</td></tr>
  <tr><td>9:30am</td><td>9:45am</td><td colspan="2">Break</td></tr>
  <tr><td>9:45am</td><td>10:30am</td><td>Contributing code</td><td>Andrew Dupont</td></tr>
  <tr><td>10:30am</td><td>11:15am</td><td>The Prototype ecosystem</td><td>TBD</td></tr>
  <tr><td>11:15am</td><td>11:30am</td><td colspan="2">Break</td></tr>
  <tr><td>11:30am</td><td>1:00pm</td><td>Extended Q&#038;A</td><td>Prototype Core</td></tr>
</tbody>
</table>

<p>You will get a chance to hook up with members of Prototype Core and &#8220;close core&#8221;, and we all look forward to meeting you guys.  Here&#8217;s the current rundown:</p>

<ul>
<li>Sam Stephenson <em>(to be confirmed)</em></li>
<li>Andrew Dupont <em>(confirmed)</em></li>
<li>Juriy &#8220;kangax&#8221; Zaytsev <em>(confirmed)</em></li>
<li>Mislav Marohnić <em>(to be confirmed)</em></li>
<li>Tobie Langel <em>(to be confirmed)</em></li>
<li>Christophe Porteneuve <em>(confirmed)</em></li>
</ul>

<p>For more information on coming with a group, contact <a href="mailto:%22Tracey%20West%22%20%3Ctwest%40techtarget.com%3E?subject=Group%20pricing%20for%20TAE">Tracey West</a>.  You can view the <a href="http://ajaxexperience.techtarget.com/east/html/eventsataglance.html?Offer=AEprot717">agenda</a> for The Ajax Experience, and then proceed to one or both of the following:</p>

<ul>
<li>Want to register for PDD?  You <strong>must</strong> use our special <a href="http://devdays.prototypejs.org">quick form</a>.  Registering for TAE <strong>doesn&#8217;t</strong> automatically sign you up for PDD, and the number of seats is pretty limited.</li>
<li><a href="http://www.regonline.com/ajaxexperience">Register for The Ajax Experience</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/07/25/first-prototype-developer-day-monday-september-29-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Looking for another approach?</title>
		<link>http://www.thebungeebook.net/2008/07/07/looking-for-another-approach/</link>
		<comments>http://www.thebungeebook.net/2008/07/07/looking-for-another-approach/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 09:14:05 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Releases]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=43</guid>
		<description><![CDATA[One size does not necessarily fit all.  Although it is my fervent hope that the very vast majority of the book&#8217;s readers found it to their liking and very useful to their endeavors, it never hurts to cross multiple approaches in order to get a better understanding of a topic.

Which is why I couldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>One size does not necessarily fit all.  Although it is my fervent hope that the very vast majority of the book&#8217;s readers found it to their liking and very useful to their endeavors, it never hurts to cross multiple approaches in order to get a better understanding of a topic.</p>

<p>Which is why I couldn&#8217;t be silent on the recent release of fellow Prototype Core member <a href="http://andrewdupont.net/">Andrew Dupont</a>&#8217;s book, <a href="http://www.amazon.com/Practical-Prototype-script-aculo-us-Andrew-Dupont/dp/1590599195">Practical Prototype and script.aculo.us</a>. Amazon has Search-Inside already, and you can <a href="http://ajaxian.com/archives/book-excerpt-practical-prototype-and-scriptaculous-advanced-ajax-chapter-4">grab a free chapter at Ajaxian</a>.</p>

<p>You&#8217;ll notice Amazon pairs Andrew&#8217;s book and mine more often then not <img src='http://www.thebungeebook.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>Andrew&#8217;s a superb Prototype expert, one of the four people, actually, having commit rights to Prototype&#8217;s repository. He&#8217;s extremely active (far more than I these days, I&#8217;m afraid) and I have every confidence his book is very useful. Check it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/07/07/looking-for-another-approach/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting Out of Binding Situations in JavaScript</title>
		<link>http://www.thebungeebook.net/2008/07/02/getting-out-of-binding-situations-in-javascript/</link>
		<comments>http://www.thebungeebook.net/2008/07/02/getting-out-of-binding-situations-in-javascript/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 06:54:01 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Articles]]></category>

		<category><![CDATA[Cool tricks]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=42</guid>
		<description><![CDATA[I&#8217;m delighted to report that my article in renowned A List Apart just went out, and it covers a pretty tricky aspect of JavaScript often misunderstood or poorly known: binding.

Head over to ALA and enjoy: Getting Out of Binding Situations in JavaScript.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m delighted to report that my article in renowned <a href="http://alistapart.com">A List Apart</a> just went out, and it covers a pretty tricky aspect of JavaScript often misunderstood or poorly known: <em>binding</em>.</p>

<p>Head over to ALA and enjoy: <a href="http://www.alistapart.com/articles/getoutbindingsituations/">Getting Out of Binding Situations in JavaScript</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/07/02/getting-out-of-binding-situations-in-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Firefox 3’s out!</title>
		<link>http://www.thebungeebook.net/2008/06/17/firefox-3s-out/</link>
		<comments>http://www.thebungeebook.net/2008/06/17/firefox-3s-out/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 20:59:29 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Releases]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=41</guid>
		<description><![CDATA[Get it now.  I&#8217;m serious.  YSlow&#8217;s there, Firebug 1.2 beta&#8217;s there, Web Developer Toolbar&#8217;s there, and it just kicks the living crap out of Firefox 2 for performance, not to mention all the cool dev-oriented stuff like more advanced JS, better extension stuff, better &#60;canvas&#62;, better SVG, better support for cutting-edge standards, and [...]]]></description>
			<content:encoded><![CDATA[<p>Get it now.  I&#8217;m serious.  YSlow&#8217;s there, Firebug 1.2 beta&#8217;s there, Web Developer Toolbar&#8217;s there, and it just kicks the living crap out of Firefox 2 for performance, not to mention all the cool dev-oriented stuff like more advanced JS, better extension stuff, better <code>&lt;canvas&gt;</code>, better SVG, better support for cutting-edge standards, and the like.</p>

<p>Get it now.  Get it today.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/06/17/firefox-3s-out/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rich autocompletion</title>
		<link>http://www.thebungeebook.net/2008/06/15/rich-autocompletion/</link>
		<comments>http://www.thebungeebook.net/2008/06/15/rich-autocompletion/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 18:12:33 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Articles]]></category>

		<category><![CDATA[Cool tricks]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=40</guid>
		<description><![CDATA[A few days ago, an astute reader of the book, Bharat Ruparel, requested an example of multiple-update autocompletion on the book&#8217;s forums. I thought it would make for a nice demo page and a post here, so here you go, Bharat.

The main idea behind autocompletion with script.aculo.us is that the possible results are sent as [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago, an astute reader of the book, Bharat Ruparel, requested an example of multiple-update autocompletion on the book&#8217;s forums. I thought it would make for a nice demo page and a post here, so here you go, Bharat.</p>

<p>The main idea behind autocompletion with script.aculo.us is that the possible results are sent as a <code>&lt;ul&gt;/&lt;li&gt;</code> list, one list item per result, and the full <em>textual</em> contents of an item (including line breaks and whitespace), except whatever contents sits inside an element with a CSS class named &#8220;informal,&#8221; are extracted to provide the completed text.</p>

<p>This behavior can be altered, however, mainly through two means:</p>

<ul>
<li>Using the <code>select</code> option to provide a CSS class name marking <em>which textual contents to use</em> (any other textual contents will be ignored)</li>
<li>Providing a custom extraction logic <em>in addition</em> to the default one through the <code>afterUpdateElement</code> callback.</li>
</ul>

<p>Both these are discussed in the book (chapter 16, which is 20 pages), but the callback approach isn&#8217;t demonstrated in-depth. For this post, I prepared a detailed demo page that I invite you all to go through.  It contains detailed explanative material around each step, from the most basic call to the full-fledged one, and tries to demonstrate the snags you can hit and how to achieve more advanced completion.</p>

<p><a href="/examples/rich-autocompletion/">Check out the full demo page!</a></p>

<p>I hope this helps, and perhaps even provides a few of you with that &#8220;Aha!&#8221; moment I cherish.</p>

<p>Cheers,</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/06/15/rich-autocompletion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Builder demo errata</title>
		<link>http://www.thebungeebook.net/2008/06/09/builder-demo-errata/</link>
		<comments>http://www.thebungeebook.net/2008/06/09/builder-demo-errata/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 08:17:31 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=39</guid>
		<description><![CDATA[A reader just brought an issue with the book&#8217;s Builder demo (chapter 17) to my attention.

The code that ships with the demo essentially grabs code pieces from the page itself, where they are displayed in table cells, to run this code live and display its result.  In doing so, it attempted to go the [...]]]></description>
			<content:encoded><![CDATA[<p>A reader just brought an issue with the book&#8217;s <code>Builder</code> demo (chapter 17) to my attention.</p>

<p>The code that ships with the <a href="http://media.pragprog.com/titles/cppsu/code/scriptaculous/builder">demo</a> essentially grabs code pieces from the page itself, where they are displayed in table cells, to run this code live and display its result.  In doing so, it attempted to go the extra mile and strip single-line comments from the code before <code>eval</code>&#8216;ing it; it isn&#8217;t mandatory, it just felt cleaner at the time.</p>

<p>However, the regular expression used b0rks on IE7.  I&#8217;m surprised nobody alerted me to that in almost 7 months since the book&#8217;s final release…</p>

<p>To get it to work in IE7, simply strip the clean-up line from the code.  That&#8217;s the following line:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript">code = code.<span style="color: #000099;">replace</span><span style="color: #ff0000;">&#40;</span><span style="color: #0066FF;">/^\s*\/\/.<span style="color: #000099;">*</span>$/mg</span>, <span style="color: #009900;">''</span><span style="color: #ff0000;">&#41;</span>;</pre></div></div>


<p>This will work just fine on all browsers now.</p>

<p>Thanks to Bharat for the heads up!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/06/09/builder-demo-errata/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Neuron Workout Solutions #6</title>
		<link>http://www.thebungeebook.net/2008/05/29/neuron-workout-solutions-6/</link>
		<comments>http://www.thebungeebook.net/2008/05/29/neuron-workout-solutions-6/#comments</comments>
		<pubDate>Thu, 29 May 2008 20:25:22 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Neuron Workouts]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=38</guid>
		<description><![CDATA[Welcome to this sixth installment of Neuron Workout Solutions™, a series that answers the questions and challenges at the end of many chapters in the book.  Boy, is this installment overdue.  I&#8217;ve been meaning to write it for weeks, but life just didn&#8217;t seem to agree. Today we&#8217;ll address the challenges closing chapter [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to this sixth installment of <strong>Neuron Workout Solutions™</strong>, a series that answers the questions and challenges at the end of many chapters in the book.  Boy, is this installment overdue.  I&#8217;ve been meaning to write it for weeks, but life just didn&#8217;t seem to agree. Today we&#8217;ll address the challenges closing chapter 12: Effects. And with this, we open up the Neuron Workouts for the script.aculo.us part of the book.</p>

<p><span id="more-38"></span></p>

<h4>Say we have half a dozen items (effects and custom code snippets) we want to queue up like pearls on a string.  What&#8217;s the best option here? <code>afterFinish</code> callbacks or a custom queue? Why?</h4>

<p>As soon as you need to queue up more than 2 or 3 effects and bits of code, I rather advocate using a custom queue.  Not only does that make for an easier manipulation of the sequence (rescheduling, pausing, whatever…), it also avoid massive nesting (usually shown with massive indenting, too).  We all found ourselves once or twice refining an increasingly-complex sequence, and winding up with something like this:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #999999; font-style: italic;">// UGLY CODE!!! //////////////////</span>
Effect.<span style="color: #000099;">A</span><span style="color: #ff0000;">&#40;</span>options, <span style="color: #ff0000;">&#123;</span>
  afterFinish: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
    <span style="color: #999999; font-style: italic;">// someCode…</span>
    Effect.<span style="color: #000099;">B</span><span style="color: #ff0000;">&#40;</span>options, <span style="color: #ff0000;">&#123;</span>
      afterFinish: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
        Effect.<span style="color: #000099;">C</span><span style="color: #ff0000;">&#40;</span>options, <span style="color: #ff0000;">&#123;</span>
          afterFinish: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
            <span style="color: #999999; font-style: italic;">// someCode…</span>
          <span style="color: #ff0000;">&#125;</span>
        <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>,
      <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>;
    <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>;
  <span style="color: #ff0000;">&#125;</span>
<span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>;</pre></div></div>


<p>Going with queues just seems nicer (especially for long effect chains), although using <code>afterFinish</code> for code interleaving is actually more concise than <code>Effect.Event</code> blocks that would, anyway, require such callbacks:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript">Effect.<span style="color: #000099;">A</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#123;</span> …, queue: <span style="color: #ff0000;">&#123;</span> scope: <span style="color: #009900;">'yourEffect'</span>, position: <span style="color: #009900;">'end'</span> <span style="color: #ff0000;">&#125;</span>, afterFinish: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
  <span style="color: #999999; font-style: italic;">// someCode…</span>
<span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>;
Effect.<span style="color: #000099;">B</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#123;</span> …, queue: <span style="color: #ff0000;">&#123;</span> scope: <span style="color: #009900;">'yourEffect'</span>, position: <span style="color: #009900;">'end'</span> <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>;
Effect.<span style="color: #000099;">C</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#123;</span> …, queue: <span style="color: #ff0000;">&#123;</span> scope: <span style="color: #009900;">'yourEffect'</span>, position: <span style="color: #009900;">'end'</span> <span style="color: #ff0000;">&#125;</span>, afterFinish: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
  <span style="color: #999999; font-style: italic;">// someCode…</span>
<span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>;</pre></div></div>


<h4>How would you queue two effects with a two-second pause between the end of the first effect and the beginning of the second one?</h4>

<p>Just use a common queue and set the second effect&#8217;s delay.  For instance:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">new</span> Effect.<span style="color: #000099;">Scale</span><span style="color: #ff0000;">&#40;</span><span style="color: #009900;">'langLink'</span>, <span style="color: #0000cc;">200</span><span style="color: #ff0000;">&#41;</span>;
<span style="color: #003366; font-weight: bold;">new</span> Effect.<span style="color: #000099;">Scale</span><span style="color: #ff0000;">&#40;</span><span style="color: #009900;">'langLink'</span>, <span style="color: #0000cc;">50</span>, <span style="color: #ff0000;">&#123;</span> queue: <span style="color: #009900;">'end'</span>, delay: <span style="color: #0000cc;">2</span> <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>;</pre></div></div>


<p>If there were already ongoing effects and you wanted the first one to wait, you&#8217;d need to use <code>queue: 'end'</code> on the first one, too. <a href="/examples/neuron-workout-solutions-6/#chainingWithPause">Check out the demo page</a>!</p>

<h4>Write horizontal blind effects (<code>Effect.BlindLeft</code> and <code>Effect.BlindRight</code>).</h4>

<p>Aaaaah, that&#8217;s the million-dollar one, right?  The question keeps popping up on the support mailing list and in many places.  Let&#8217;s look at how <code>BlindUp</code> and <code>BlindDown</code> are implemented.  The &#8216;up&#8217; version first, as it&#8217;s the simplest one:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript">Effect.<span style="color: #000099;">BlindUp</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span>element<span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
  element = $<span style="color: #ff0000;">&#40;</span>element<span style="color: #ff0000;">&#41;</span>;
  element.<span style="color: #000099;">makeClipping</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span>;
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> Effect.<span style="color: #000099;">Scale</span><span style="color: #ff0000;">&#40;</span>element, <span style="color: #0000cc;">0</span>,
    Object.<span style="color: #000099;">extend</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#123;</span> scaleContent: <span style="color: #003366; font-weight: bold;">false</span>, 
      scaleX: <span style="color: #003366; font-weight: bold;">false</span>, 
      restoreAfterFinish: <span style="color: #003366; font-weight: bold;">true</span>,
      afterFinishInternal: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span>effect<span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
        effect.<span style="color: #000099;">element</span>.<span style="color: #000099;">hide</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span>.<span style="color: #000099;">undoClipping</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span>;
      <span style="color: #ff0000;">&#125;</span> 
    <span style="color: #ff0000;">&#125;</span>, arguments<span style="color: #ff0000;">&#91;</span><span style="color: #0000cc;">1</span><span style="color: #ff0000;">&#93;</span> || <span style="color: #ff0000;">&#123;</span> <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>
  <span style="color: #ff0000;">&#41;</span>;
<span style="color: #ff0000;">&#125;</span>;</pre></div></div>


<p>OK, so what is Scripty doing here?</p>

<ol>
<li>First, we state we&#8217;re not interested in resizing the contents (that&#8217;s not what &#8220;blinds&#8221; effects do), and ensure the content won&#8217;t overflow once we start reducing the element&#8217;s surface: that&#8217;s what <code>makeClipping</code> is for; it sets the element&#8217;s <code>overflow</code> CSS property to <code>hidden</code>.</li>
<li>Then scale, vertically only, from the current size (whatever it is) to zero.</li>
<li>And some cleanup code when we&#8217;re done: hide the element, restore its <code>overflow</code> CSS property&#8217;s previous value, and restore its original size.  This is the sort of cleanup that makes it possible to hide and element with <code>BlindUp</code> and show it again with <code>Appear</code> or <code>SlideDown</code>, for instance.</li>
</ol>

<p>We could very well transform this to suite <code>BlindLeft</code>.  What&#8217;s changing here, basically?  Well, instead of disabling horizontal resizing (using <code>scaleX: false</code>, we would need to disable <em>vertical</em> resizing. As <code>BlindUp</code> is graciously allowing us to override its default options set with our own, let&#8217;s try this out:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript">Effect.<span style="color: #000099;">BlindLeft</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span>element<span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> Effect.<span style="color: #000099;">BlindUp</span><span style="color: #ff0000;">&#40;</span>element, Object.<span style="color: #000099;">extend</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#123;</span>
    scaleX: <span style="color: #003366; font-weight: bold;">true</span>, scaleY: <span style="color: #003366; font-weight: bold;">false</span>
  <span style="color: #ff0000;">&#125;</span>, arguments<span style="color: #ff0000;">&#91;</span><span style="color: #0000cc;">1</span><span style="color: #ff0000;">&#93;</span> || <span style="color: #ff0000;">&#123;</span><span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span><span style="color: #ff0000;">&#41;</span>;
<span style="color: #ff0000;">&#125;</span>;</pre></div></div>


<p>First, a reminder about <code>Blind</code>… effects: for best results, you would need to avoid padding on the container; otherwise, size computation will mix up and you&#8217;ll start larger than you originally were. What you usually end up doing is wrap the whole contents inside another element, which has the proper padding, if you need any.</p>

<p>There&#8217;s only one specific gotcha with the code we just saw: you need to work around line wrapping.  This is not an issue on vertical blinds, because text flows horizontally in browsers (so far, at least ;-)).  But when blinding sideways, we change the container&#8217;s width, and its textual contents, if any, will wrap accordingly.  For simple stuff, we can just get around with a <code>white-space: nowrap</code> CSS definition.</p>

<p>Sparing us that requirement, therefore enabling sideways blinds on random textual contents, would probably require an extra level of containment, much like <code>SlideUp</code> and <code>SlideDown</code> require, in order to play with internal positions.  We&#8217;ll not dive into this here, but you&#8217;re welcome to share suggestions and demos in the comments!</p>

<p>So guess what?!  It works!  <a href="/examples/neuron-workout-solutions-6/#sidewaysBlinds">Check out the demo page</a>!</p>

<p>The original <code>BlindDown</code> is a tad more tricky, but we don&#8217;t care: its code wouldn&#8217;t fit our <code>BlindRight</code> needs anyway. Because unlike up, left and down, a right-hand blind will not only resize the element, it will <em>move it</em>.</p>

<p>Basically, we need to synchronize two effects here:</p>

<ol>
<li>A <code>Move</code> to push the element to the right by its width</li>
<li>A <code>Scale</code> to reduce its size</li>
<li>We need to store the original position to restore it in the end, as we&#8217;re not supposed to keep the element moved aside…</li>
</ol>

<p>It&#8217;s actually rather straightforward.  Here we go:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript">Effect.<span style="color: #000099;">BlindRight</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span>element<span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> Effect.<span style="color: #000099;">Parallel</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#91;</span>
    Effect.<span style="color: #000099;">BlindUp</span><span style="color: #ff0000;">&#40;</span>element, <span style="color: #ff0000;">&#123;</span> scaleX: <span style="color: #003366; font-weight: bold;">true</span>, scaleY: <span style="color: #003366; font-weight: bold;">false</span>, sync: <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>,
    <span style="color: #003366; font-weight: bold;">new</span> Effect.<span style="color: #000099;">Move</span><span style="color: #ff0000;">&#40;</span>element, <span style="color: #ff0000;">&#123;</span> sync: <span style="color: #003366; font-weight: bold;">true</span>, x: $<span style="color: #ff0000;">&#40;</span>element<span style="color: #ff0000;">&#41;</span>.<span style="color: #000099;">getWidth</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span>, y: <span style="color: #0000cc;">0</span> <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>
  <span style="color: #ff0000;">&#93;</span>, Object.<span style="color: #000099;">extend</span><span style="color: #ff0000;">&#40;</span>arguments<span style="color: #ff0000;">&#91;</span><span style="color: #0000cc;">1</span><span style="color: #ff0000;">&#93;</span> || <span style="color: #ff0000;">&#123;</span><span style="color: #ff0000;">&#125;</span>, <span style="color: #ff0000;">&#123;</span>
    afterFinishInternal: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
      element.<span style="color: #000099;">setStyle</span><span style="color: #ff0000;">&#40;</span><span style="color: #ff0000;">&#123;</span> left: left, top: top <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span>;
    <span style="color: #ff0000;">&#125;</span>
  <span style="color: #ff0000;">&#125;</span><span style="color: #ff0000;">&#41;</span><span style="color: #ff0000;">&#41;</span>;
<span style="color: #ff0000;">&#125;</span>;</pre></div></div>


<p>Notice the <code>afterFinishInternal</code> callback, specifically designed for actual, internal callbacks in custom effects. This is also a nice example of <code>Effect.Parallel</code> in action for synchronized parallel execution.</p>

<p>Yay!  That&#8217;s pretty short indeed.   <a href="/examples/neuron-workout-solutions-6/#sidewaysBlinds">Check out the demo page</a> for a live demo!</p>

<h4>How could we turn any effect into a permanent loop?</h4>

<p>Well, I wish we could just whip up a solution with a custom transition function; that would be an elegant way of doing it. However, that just won&#8217;t do: a transition essentially says which position to <em>render</em> instead of the original position (which always goes from zero to one in one smooth linear go). It does <em>not</em> change the effect&#8217;s duration, which means we can&#8217;t get &#8220;permanent loop&#8221; with a transition.</p>

<p>The trick below relies on the effects engine implementation up to version 1.8.1. It won&#8217;t work in the future &#8220;Scripty2,&#8221; although there&#8217;s another possible way there.</p>

<p>The idea is that the original position progression, maintained internally by the effects engine and not modifiable by callbacks, is based on the effect&#8217;s internal <code>startOn</code> and <code>finishOn</code> properties, as described around the end of the book&#8217;s effects chapter. But it doesn&#8217;t reinspect these properties all the time: it&#8217;s only based on their values <em>at effect initialization time</em>. However, the engine relies on these properties at every frame, which means that <em>if we change the effect&#8217;s ending time post-initialization, we&#8217;ll get it to run positions way above one.</em></p>

<p>That <em>sounds</em> like this is an issue, but with the most common transitions, it&#8217;s not.  Most rely on conversions through the trigonometric circle, which boils down to this: any position is &#8220;modulo 2:&#8221; from 0 to 1 goes forward, from 1 to 2 goes backward. Such transitions include <code>sinoidal</code> (the default one), <code>flicker</code>, <code>wobble</code> and <code>spring</code>.</p>

<p>Therefore, tricking any effect into becoming a permanent forth-and-back loop is as simple as changing its internal <code>finishOn</code> property to be in the infinite future, post-initialization.  This could just mean passing the following callback in:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript">beforeSetup: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #ff0000;">&#40;</span>effect<span style="color: #ff0000;">&#41;</span> <span style="color: #ff0000;">&#123;</span>
  effect.<span style="color: #000099;">finishOn</span> = Number.<span style="color: #000099;">POSITIVE_INFINITY</span>;
<span style="color: #ff0000;">&#125;</span></pre></div></div>


<p>Isn&#8217;t this great?  On the demo page, you&#8217;ll be able to see <a href="/examples/neuron-workout-solutions-6/#loop">a looped example of all other demos</a>.</p>

<h4>Disclaimer</h4>

<p>I&#8217;ve had so little time to try and squeeze this through that I couldn&#8217;t test on IE6+ (works beautifully on Firefox 2+, Opera 9.22+ and Safari 2+.  If there are any issues, please report them in the comments or through direct e-mail.</p>

<h4>And that&#8217;s a wrap!</h4>

<p>I&#8217;ll look forward to any questions, comments or wild guesses you may have.  And stay tuned for the seventh installment!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/05/29/neuron-workout-solutions-6/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reprint!</title>
		<link>http://www.thebungeebook.net/2008/05/16/reprint/</link>
		<comments>http://www.thebungeebook.net/2008/05/16/reprint/#comments</comments>
		<pubDate>Fri, 16 May 2008 21:31:26 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thebungeebook.net/?p=37</guid>
		<description><![CDATA[The original 5,000 paper copies are just about sold out, and channels keep asking for more!  So I&#8217;m happy to announce Pragmatic Programmers just triggered a reprint of 3,000 more copies.

Thanks to everyone for grabbing the book, I hope you&#8217;re loving it!
]]></description>
			<content:encoded><![CDATA[<p>The original 5,000 paper copies are just about sold out, and channels keep asking for more!  So I&#8217;m happy to announce Pragmatic Programmers just triggered a reprint of 3,000 more copies.</p>

<p>Thanks to everyone for grabbing the book, I hope you&#8217;re loving it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebungeebook.net/2008/05/16/reprint/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
