<?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>Caridy - Random Bubbles</title>
	<atom:link href="http://caridy.name/feed/" rel="self" type="application/rss+xml" />
	<link>http://caridy.name</link>
	<description>Javascript, YUI, AJAX and Advanced Web Apps</description>
	<lastBuildDate>Mon, 16 Nov 2009 22:56:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting up to speed with YUI 3</title>
		<link>http://caridy.name/2009/11/getting-up-to-speed-with-yui-3/</link>
		<comments>http://caridy.name/2009/11/getting-up-to-speed-with-yui-3/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 22:56:26 +0000</pubDate>
		<dc:creator>caridy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://caridy.name/?p=175</guid>
		<description><![CDATA[Few folks has asked me about YUI 3.0 and how they can get up to speed with this new version of Yahoo! User Interface Library. Well, here is a quick guide to get up to speed in 3 days. Yes you heard me right, only 3 days, assuming you already know JavaScript and YUI 2. [...]]]></description>
			<content:encoded><![CDATA[<p>Few folks has asked me about <a href="http://developer.yahoo.com/yui/3/">YUI 3.0</a> and how they can get up to speed with this new version of <a href="http://developer.yahoo.com/yui/">Yahoo! User Interface Library</a>. Well, here is a quick guide to get up to speed in 3 days. Yes you heard me right, only 3 days, assuming you already know JavaScript and <a href="http://developer.yahoo.com/yui/2/">YUI 2</a>. <img src='http://caridy.name/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<h3>First block (day one) &#8211; General Architecture</h3>
<p>In the first day, you will have to expend around 4 hours watching videos, getting a lot of information. There is not time to tackle this little by little, hahahaha.  It&#8217;s better to get the whole insight in a row.</p>
<p><strong>(Day 1, Task 1). General Concepts</strong></p>
<p style="padding-left: 30px;">Let&#8217;s start with a general talk by Nicholas. He really explores some of the basic design principles used to build YUI 3. He didn&#8217;t mention YUI 3, but I believe if you understand these general concepts, will be easy for you to understand YUI 3.</p>
<p style="padding-left: 30px;"><a href="http://developer.yahoo.com/yui/theater/video.php?v=zakas-architecture"><strong>Nicholas C. Zakas — Scalable JavaScript Application Architecture</strong></a><br />
Frontend architecture for complex, modular web applications with significant JavaScript elements.<br />
<a href="http://developer.yahoo.com/yui/theater/video.php?v=zakas-architecture">http://developer.yahoo.com/yui/theater/video.php?v=zakas-architecture</a></p>
<p style="padding-left: 30px;">Then you can jump for the real stuff. These 3 videos were recorded during YUI Conf 2009, and are essential in the process of understanding the underlying concepts behind YUI 3.</p>
<p><strong>(Day 1, Task 2). YUI Infrastructure</strong></p>
<p style="padding-left: 30px;"><a href="http://developer.yahoo.com/yui/theater/video.php?v=miraglia-yuiconf2009-yui3">Eric Miraglia — Welcome to YUI 3</a><br />
YUI engineer Eric Miraglia provides a high-level introduction to key concepts underlying the YUI 3 codeline.<br />
<a href="http://developer.yahoo.com/yui/theater/video.php?v=miraglia-yuiconf2009-yui3">http://developer.yahoo.com/yui/theater/video.php?v=miraglia-yuiconf2009-yui3 </a></p>
<p><strong>(Day 1, Task 3). Events Infrastructure</strong></p>
<p style="padding-left: 30px;"><a href="http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-events">Luke Smith — Events Evolved</a><br />
YUI engineer Luke Smith provides a deep introduction to the YUI 3 event system including its support for DOM events, event delegation, synthetic events, and custom events.<br />
<a href="http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-events">http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-events</a></p>
<p><strong>(Day 1, Task 4). Widget Infrastructure<br />
</strong></p>
<p style="padding-left: 30px;"><strong> </strong> <a href="http://developer.yahoo.com/yui/theater/video.php?v=desai-yuiconf2009-widgets">Satyen Desai — A Widget Walkthrough</a><br />
YUI engineer Satyen Desai provides a detailed tour of the YUI 3 widget subsystem. (Slides).<br />
<a href="http://developer.yahoo.com/yui/theater/video.php?v=desai-yuiconf2009-widgets">http://developer.yahoo.com/yui/theater/video.php?v=desai-yuiconf2009-widgets</a></p>
<h3>Second Block (day two) &#8211; Experimenting</h3>
<p>In this second block you will be able to get some insight, checking some real examples, and getting some feeling about the new code style and the new infrastructure.</p>
<p><strong><strong>(Day 2, Task 1). </strong>Playing with the Official Examples</strong></p>
<p style="padding-left: 30px;">You should spend some time checking some of these examples. Keep in mind that for every example in the library we have a page with the full explanation, this can help you to understand better how things work. Here is an <a href="http://developer.yahoo.com/yui/3/examples/anim/basic.html">example</a>, and has you can see, there is a link to display the <a href="http://developer.yahoo.com/yui/3/examples/anim/basic_clean.html">working example</a> in a new page, or you can see it within the iframe and the description is below that.</p>
<p style="padding-left: 30px;"><a href="http://developer.yahoo.com/yui/3/examples/">YUI 3: Index of Examples</a><br />
YUI 3 ships with a series of 130 examples that illustrate the implementation of its components. The examples can be starting points for your exploration, code snippets to jump-start your own programming, or simply inspiration as to how various interaction patterns can be enabled in the web browser via YUI.<br />
<a href="http://developer.yahoo.com/yui/3/examples/">http://developer.yahoo.com/yui/3/examples/</a></p>
<p><strong><strong>(Day 2, Task 2). </strong>Checking the state of the library<br />
</strong></p>
<p style="padding-left: 30px;">It&#8217;s important to understand the state of the library, the list of available modules, and the state of each module. Keep in mind that every module contains a landing page with some information (the most important), but there are some more pages and the API Docs with tons of valuable info. Don&#8217;t spend too much time digging from here, it&#8217;s better to explore each component when needed, having a real use-case in mind.<a href="http://developer.yahoo.com/yui/3/"><br />
http://developer.yahoo.com/yui/3/</a></p>
<p style="padding-left: 30px;">Try to focus on &#8220;Core&#8221; and &#8220;Component Infrastructure&#8221; sections. Also, spend some time reviewing the <a href="http://developer.yahoo.com/yui/3/configurator/">dependency configurator</a> tool, it will give you some feeling about the granularity and the organization.<br />
<a href="http://developer.yahoo.com/yui/3/configurator/">http://developer.yahoo.com/yui/3/configurator/</a></p>
<p><strong>(Day 2, Task 3). Debugging</strong></p>
<p style="padding-left: 30px;">Now that you have nailed down some of the general concepts, and you will start checking some examples and putting some examples on your own, it’s important to know how the debug your code. YUI 3 offers a variety of tools and utilities to help you during the development process:</p>
<p style="padding-left: 30px;"><a href="http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-debugging">Luke Smith — Debugging in YUI 3</a><br />
YUI engineer Luke Smith discusses the fine art of debugging web applications, looking at general tools and techniques and providing a few specific hints about debugging in YUI 3.<br />
<a href="http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-debugging">http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-debugging</a></p>
<p><strong>(Day 2, Task 4). Performance Implications</strong></p>
<p style="padding-left: 30px;">With YUI 3 we are trying to beat all the barriers in terms of performance. Normally is not recommended to introduce performance optimization in the early stages for a project, it&#8217;s important to know the general concepts behind YUI 3 Loading process, and how to leverage YUI 3 infrastructure to create hight performance web applications.</p>
<p style="padding-left: 30px;"><a href="http://developer.yahoo.com/yui/theater/video.php?v=sweeney-yuiconf2009-performance">Matt Sweeney — YUI 3 Performance</a><br />
YUI architect Matt Sweeney reviews principles of high-performance web development and looks at how best to implement those principles in YUI 3-based projects.<br />
<a href="http://developer.yahoo.com/yui/theater/video.php?v=sweeney-yuiconf2009-performance">http://developer.yahoo.com/yui/theater/video.php?v=sweeney-yuiconf2009-performance</a></p>
<p>After that, you should be able to continue with the library documentation and the examples.</p>
<h3>Third Block (day three) &#8211;  Extending and Contributing</h3>
<p><strong>(Day 3, Task 1). Creating your own modules</strong></p>
<p style="padding-left: 30px;"><a href="http://www.slideshare.net/caridy/building-yui-3-custom-modules">Caridy Patino &#8211; Building YUI 3 Custom Modules</a><br />
Learn how to leverage the YUI 3.x infrastructure to create custom code that can be loaded easily and efficiently onto any page. Also discover how these mashups can combine YUI widgets and utilities with your own code and how to reuse code between different YUI instances.<br />
<a href="http://www.slideshare.net/caridy/building-yui-3-custom-modules">http://www.slideshare.net/caridy/building-yui-3-custom-modules</a></p>
<p><strong>(Day 3, Task 2). A real world use-case</strong></p>
<p style="padding-left: 30px;">In every project, is always good to get a different angle, a different perspective, and outsider insight:</p>
<p style="padding-left: 30px;"><a href="http://developer.yahoo.com/yui/theater/video.php?v=ericf-yuiconf2009-webapps">Eric Ferraiuolo — Web App Development with YUI 3</a><br />
Eric Ferraiuolo of Oddnut Software talks about the nuances of deploying real-world web applications using YUI 3.<br />
<a href="http://developer.yahoo.com/yui/theater/video.php?v=ericf-yuiconf2009-webapps">http://developer.yahoo.com/yui/theater/video.php?v=ericf-yuiconf2009-webapps</a></p>
<p><strong>(Day 3, Task 3). How to contributing to YUI</strong></p>
<p style="padding-left: 30px;">If you&#8217;re really into YUI, you should take the time to check this awesome video from Dav Glass:</p>
<p style="padding-left: 30px;"><a href="http://developer.yahoo.com/yui/theater/video.php?v=glass-yuiconf2009-contributing">Dav Glass — Contributing to YUI</a><br />
YUI engineer Dav Glass introduces you to the YUI Gallery and steps through the process of making contributions to the YUI project.<br />
<a href="http://developer.yahoo.com/yui/theater/video.php?v=glass-yuiconf2009-contributing">http://developer.yahoo.com/yui/theater/video.php?v=glass-yuiconf2009-contributing</a></p>
<p style="padding-left: 30px;">Check the YUI 3 gallery here:<br />
<a href="http://yuilibrary.com/gallery/">http://yuilibrary.com/gallery/</a></p>
<h3>Few more thoughts</h3>
<p>There is a bunch of videos in the <a href="http://developer.yahoo.com/yui/theater/">YUI Theater</a>, make sure that you check them, some of them are really useful, other are very technical or diving into an specific subject. Also, there are a bunch of them explaining in details some of the tools created by YUI Team as well.<br />
<a href="http://developer.yahoo.com/yui/theater/">http://developer.yahoo.com/yui/theater/</a></p>
<p>YUI Blog is another good reason to keep you updated about the library. Including some good articles (again, some technical deep dive).<br />
<a href="http://www.yuiblog.com/">http://www.yuiblog.com/</a></p>
<p>And finally, you can join us thru the community. <a href="http://yuilibrary.com/">This site</a>, with such a great organization, provides multiple ways to get in contact with YUI Core Team, YUI Contributors and the community in general.<br />
<a href="http://yuilibrary.com/">http://yuilibrary.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://caridy.name/2009/11/getting-up-to-speed-with-yui-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bootstrap using &#8220;YUI Loader&#8221; and &#8220;YUI Get Utility&#8221;</title>
		<link>http://caridy.name/2009/05/bootstrap-using-yui-loader-and-yui-get-utility/</link>
		<comments>http://caridy.name/2009/05/bootstrap-using-yui-loader-and-yui-get-utility/#comments</comments>
		<pubDate>Thu, 07 May 2009 22:25:24 +0000</pubDate>
		<dc:creator>caridy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[loader]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://caridy.name/?p=149</guid>
		<description><![CDATA[Everyday more and more developers use on-demand loading to improve performance and round &#8220;trip&#8221; times for web applications and even for traditional web pages that require a certain amount of JavaScript code.
In YUI 2.x, we have two components that can help us to define on-demand rules. These are the YUI Get Utility, and the YUI [...]]]></description>
			<content:encoded><![CDATA[<p>Everyday more and more developers use on-demand loading to improve performance and round &#8220;trip&#8221; times for web applications and even for traditional web pages that require a certain amount of JavaScript code.</p>
<p>In YUI 2.x, we have two components that can help us to define on-demand rules. These are the <a href="http://developer.yahoo.com/yui/get/">YUI Get Utility</a>, and the <a href="http://developer.yahoo.com/yui/yuiloader/">YUI Loader</a>.</p>
<p>YUI 3.x is a different story, this new version is based on the on-demand philosophy, and because of that, Loader and Get Utility are part of YUI Core.</p>
<h3>About this article:</h3>
<p>In this article, I will focus on <a href="http://developer.yahoo.com/yui/">YUI 2.x</a> and specifically, how you can design your application to use the <em>YUI on-demand capabilities</em> in such a way that the transition to <a href="http://developer.yahoo.com/yui/3/">YUI 3.x</a> will be straightforward. The main goal is to describe how we can use YUI to organize the code and learn how to deal with <em>on-demand loading processes</em> rather than focus on performance improvements. If you are looking for a performance boost, certainly this technique can help, but I will recommend you to follow the links provided at the bottom of this article.</p>
<p>From my point of view, there are two different types of web applications or pages:</p>
<ul>
<li><em>Monolithic Applications</em>:<br />
The application and all its features/behaviors are controlled by a single object/script. Modifications in the application usually impact the core and the application in general.</li>
<li><em>Granular Applications</em>:<br />
The application is based on regions/webparts that represent certain areas. Usually some of these regions/webparts can be switched or removed from the application without impacting the rest of the functionalities.</li>
</ul>
<p>I believe the second option (granular applications) is the way to go, especially for more complex applications. Also, this option will most likely make use of on-demand loading, where each region/webpart should be able to load its requirements and execute its own initialization process when it&#8217;s requirements become active and it&#8217;s DOM structure becomes available in the DOM.</p>
<p>Note: <em>regions/webparts are atomic units used to build each page. Usually they are represented in the DOM as a simple DIV, and are contained as a granular part in the application. From now on, I will refer to these elements as &#8220;regions&#8221;.</em></p>
<p>That said, lets see a couple of diagrams to analyze what is the gain behind the on-demand loading process. These are manually created diagrams representing the loading and execution process for a page.</p>
<h3>Application timeline:</h3>
<p>These two diagrams represent a page/app in which, for the sake of example,  contain only two regions (left-column-renderer and ad-renderer).</p>
<p><strong>Traditional process</strong>: inserting tags within default DOM structure of every page.</p>
<div class="wp-caption aligncenter" style="width: 615px"><img title="Default Browser Loader: Loading and Execution Timeline" src="http://caridy.name/imgs/browser-timeline.jpg" alt="Default Browser Loader: Loading and Execution Timeline" width="605" height="321" /><p class="wp-caption-text">Default Browser Loader: Loading and Execution Timeline</p></div>
<p><em>Notes for this diagram</em>:</p>
<ul>
<li>it represents a generic app timeline for a simple page with a bunch of script tags.</li>
<li>the scripts can be at the top (in the head) or at the bottom of the page (before &lt;/body&gt;), and the sequence is more or less the same.</li>
<li>&#8220;<a title="YUI Modules" href="http://developer.yahoo.com/yui/yuiloader/#modulenames">yui-modules</a>&#8221; represent a set of YUI modules (probably using <a title="YUI Combo Handler" href="http://yuiblog.com/blog/2008/07/16/combohandler/">YUI Combo Handler</a> to include them all using  a single call.</li>
<li>&#8220;<a title="Bubbling Library YUI Extension" href="http://bubbling-library.com">bubbling</a>&#8221; is a 3rd party module that cannot be loaded thru the YUI Combo Handler.</li>
<li>&#8220;swf-object&#8221; is a well-known 3rd party component to handle flash movies, and it represents another requirement.</li>
<li>&#8220;<em>&#8230;other&#8230;</em>&#8221; represents other regions in the application.</li>
</ul>
<p><strong>On-demand loading process</strong>: using YUI Loader to load the requirements and YUI Get Utility to execute the initialization processes for each region.</p>
<div class="wp-caption aligncenter" style="width: 610px"><img title="YUI Loader and Get Utility: Loading and Execution Timeline" src="http://caridy.name/imgs/yui-loader-timeline.jpg" alt="Loading and Execution Timeline" width="600" height="400" /><p class="wp-caption-text">YUI Loader and Get Utility: Loading and Execution Timeline</p></div>
<p><em>Notes for this diagram</em>:</p>
<ul>
<li>we use some of the elements described in the previous one.</li>
<li>&#8220;yui-loader&#8221; is a small file (only 9.4KB) and it packages <a href="http://developer.yahoo.com/yui/yahoo/">Yahoo Global Object</a>, <a href="http://developer.yahoo.com/yui/get/">Get Utility</a>, and <a href="http://developer.yahoo.com/yui/yuiloader/">YUI Loader</a> engine.</li>
<li>&#8220;boot&#8221; is usually a tiny file with the application logic, the definition of the 3rd party modules (swf-object and bubbling), and the list of other dependencies (initializers and renderers) that should be loaded thru YUI Get Utility (like left-column-renderer, ad-renderer, etc).</li>
<li>items at the same level can be executed at the same time (JavaScript is a single execution thread, and so, the first to become ready will be the first to be executed).</li>
<li>swf-object was transformed into a YUI Module to fit this example (it can be also be treated as a component if you want to).</li>
<li>items in the 3rd block (left-column-renderer, ad-renderer, etc) will be included dynamically by the bootstrap definition.</li>
</ul>
<p><strong>Lets try to identify differences between these two approaches:</strong></p>
<p>The first difference that you may notice in these two diagrams is the &#8220;domready&#8221; event. It will be more likely to arrive first in the second approach because those scripts will be injected on-demand without blocking the loading process. It could arrive even before the &#8220;bootstrap ready&#8221; mark, depending on the complexity (size) of the DOM structure.</p>
<p>In theory, the bootstrap is responsible in defining what should be loaded and executed after the &#8220;bootstrap ready&#8221; moment occurs. This means that we can control everything at the JS level instead of depending on the default DOM structure. So all the logic will be at the JS layer and we should be able to delay certain initialization processes, or switch between them based on the user preferences, etc. All this <em>granularity</em> will be handled at the JS level.</p>
<h3>Lets see some code:</h3>
<p><em>Entry Point (index.html):</em></p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Bootstrapping for a Web App using YUI 2.x&lt;/title&gt;
    &lt;script type="text/javascript" src="bootstrap.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body class="yui-skin-sam"&gt;
	&lt;p&gt;Web App.&lt;/p&gt;
	&lt;div id="mod-left-column"&gt;
	  ...
	&lt;/div&gt;
	&lt;div id="mod-content"&gt;
	  ...
	&lt;/div&gt;
	&lt;div id="mod-ads"&gt;
	  ...
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</div>
</div>
<p><em>Bootstrap script (bootstrap.js):</em></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*
 * Encapsulation Pattern: Conjuring YUI from thin air (by Chris Heilmann)
 * http://www.wait-till-i.com/2008/08/02/conjuring-yui-from-thin-air/
 */</span>
YAHOO_config <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009966; font-style: italic;">/* injecting the YUI Loader in the current page */</span>
    <span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    s.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'type'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'text/javascript'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    s.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'http://yui.yahooapis.com/2.7.0/build/yuiloader/yuiloader-min.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// true if the library should be dynamically loaded after window.onload.</span>
        injecting<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        listener<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// waiting for the loader component</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>o.<span style="color: #000066;">name</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'get'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>YAHOO_config.<span style="color: #660066;">ready</span><span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        ready<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> loader <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">YUILoader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #006600; font-style: italic;">// defining custom modules</span>
            loader.<span style="color: #660066;">addModule</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'bubbling'</span><span style="color: #339933;">,</span>
                type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'js'</span><span style="color: #339933;">,</span>
                fullpath<span style="color: #339933;">:</span> <span style="color: #3366CC;">'bubbling/bubbling.js'</span><span style="color: #339933;">,</span>
                requires<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'yahoo'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'event'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'dom'</span><span style="color: #009900;">&#93;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            loader.<span style="color: #660066;">addModule</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'swfobject'</span><span style="color: #339933;">,</span>
                type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'js'</span><span style="color: #339933;">,</span>
                fullpath<span style="color: #339933;">:</span> <span style="color: #3366CC;">'tools/swf-object.js'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            loader.<span style="color: #660066;">require</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'bubbling'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'swfobject'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            loader.<span style="color: #660066;">combine</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            loader.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
                onSuccess<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #009966; font-style: italic;">/* initializers and renderers here */</span>
                    YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Get</span>.<span style="color: #660066;">script</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>
                        <span style="color: #3366CC;">&quot;left-column-renderer.js&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;ad-renderer.js&quot;</span>
                    <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
                        onSuccess<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #006600; font-style: italic;">/* we are ready to roll, now we can
                               do more initializations here */</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #006600; font-style: italic;">/* more initializations here, if
                       you don't want to use Get Utility */</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The developer should define the generic structure for the application within the bootstrap, specifying the requirements, components, and modules for the application. So, basically, the bootstrap would be different for each site, application (or even for page).</p>
<h3>Identify what should be loaded using YUI Loader or YUI Get Utility:</h3>
<p>The difference between the modules and components/initializers/renderers is that modules are structures based on YUI, with the corresponding registration process, and the components are simple JS files.</p>
<p>All <a href="http://developer.yahoo.com/yui/yuiloader/#modulenames">YUI components/utilities/widgets</a> (modules) should be loaded thru the YUI Loader (along with 3rd party modules), and will be loaded on the page once.</p>
<p>YUI Get Utility should load scripts that implement a certain initialization/renderer process for a region in your application, or some kind of delayed routine to enhance the page.</p>
<h3><strong>Initialization and renderer processes:</strong></h3>
<p>Loader&#8217;s &#8220;onSuccess&#8221; is the first stop in the loading process (&#8221;bootstrap ready&#8221; in the diagram). At this point we can decide if we want to put all the initialization process within that function, or if we want to load some JavaScript files, and they will carry on with the initialization process for each different region in the page, getting some granularity for each page.</p>
<p>The initialization/renderer process should wait until the DOM structure that represent the region that we want to enhance gets available (<a href="http://developer.yahoo.com/yui/event/#onavailable">onAvailable or onContentReady</a>). If we want to extend/expand that DOM structure, just wait until DOM gets ready (<a href="http://developer.yahoo.com/yui/event/#ondomready">onDOMReady</a>) to avoid malfunctions in IE. Here is an example:</p>
<p><em>Left Column Renderer (mod-left-column.js)</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">onAvailable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mod-left-column'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #009966; font-style: italic;">/* initialization process here */</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In this case, we should include all the requirements before this block is executed.</p>
<p>In YUI 3.x, things are a lot easier. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'node'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'json'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'io'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> node <span style="color: #339933;">=</span> Y.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mod-left-column'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009966; font-style: italic;">/* initialization process here */</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Instead of including all the necessary requirements (modules) at the bootstrap level, YUI 3.x Loader will do it automatically during each region&#8217;s initialization process</p>
<h3><strong>Real examples:</strong></h3>
<ul>
<li>Simple implementation of the above example:<br />
<a title="Bootstrapping for a Web App using YUI 2.x" href="http://bubbling-library.com/sandbox/yui2/bootstrap/index.html">http://bubbling-library.com/sandbox/yui2/bootstrap/index.html</a></li>
<li>Simple implementation (experimental) on top of YUI 3 PR1:<br />
<a title="Bootstrapping for a Web App using YUI 3.x" href="http://bubbling-library.com/sandbox/yui3/bootstrap/index.html">http://bubbling-library.com/sandbox/yui3/bootstrap/index.html</a></li>
</ul>
<h3>Final notes:</h3>
<ul>
<li>The loader object can be used at any time, even during a region initialization part. It&#8217;s a good practice in YUI 2.x to have a single  reference for the loader. With small changes in the code, we can easily share and re-use the &#8220;loader&#8221; object thru &#8220;<em><a href="http://developer.yahoo.com/yui/yahoo/#config">YAHOO_config</a>.loader</em>&#8220;, across the application.</li>
<li>CSS files can be loaded thru YUI Loader or YUI Get Utility in the same way as JavaScript files.</li>
<li>For production, it&#8217;s a good practice to minimize the number of request (JavaScript files). In this case you can combine all the 3rd party modules in a single file, and even combine all the components/initializers/renderers in a single file.</li>
<li>Using inline JavaScript blocks to initialize some of the regions is not a good option; they <a title="Positioning Inline Scripts by Steve Souders" href="http://www.stevesouders.com/blog/2009/05/06/positioning-inline-scripts/">block the rendering of everything in the page</a>.</li>
</ul>
<h3><strong>More Information:</strong></h3>
<p>There are a lot of good articles about on-demand loading and how it helps to improve the performance, as well as its implications. Here are some of them:</p>
<ul>
<li>Conjuring YUI from thin air <em>by <span class="fn">Christian Heilmann</span></em><br />
<a title="Conjuring YUI from thin air" href="http://www.wait-till-i.com/2008/08/02/conjuring-yui-from-thin-air/">http://www.wait-till-i.com/2008/08/02/conjuring-yui-from-thin-air/</a></li>
<li>YUI Loader with Combo Handler <em>by Eric Miraglia</em><br />
<a title="YUI Loader with Combo Handler" href="http://yuiblog.com/blog/2008/10/17/loading-yui/">http://yuiblog.com/blog/2008/10/17/loading-yui/</a></li>
<li>Loading Scripts Without Blocking <em>by Steve Souders</em><br />
<a title="Loading Scripts Without Blocking" href="http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking">http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking</a></li>
<li>Positioning Inline Scripts <em>by Steve Souders</em><br />
<a title="Positioning Inline Scripts by Steve Souders" href="http://www.stevesouders.com/blog/2009/05/06/positioning-inline-scripts/"> http://www.stevesouders.com/blog/2009/05/06/positioning-inline-scripts/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://caridy.name/2009/05/bootstrap-using-yui-loader-and-yui-get-utility/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>YUI3: Controlling key strokes events (keyup, keydown, keypress)</title>
		<link>http://caridy.name/2009/03/yui3-keystroke-events/</link>
		<comments>http://caridy.name/2009/03/yui3-keystroke-events/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 03:27:01 +0000</pubDate>
		<dc:creator>caridy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[yui3]]></category>

		<guid isPermaLink="false">http://caridy.name/?p=45</guid>
		<description><![CDATA[In this post I want to cover the general specifications related with keystrokes in YUI3. Basically you will see few examples and a bunch of links to the official api.]]></description>
			<content:encoded><![CDATA[<p>In this post I want to cover the general specifications related with keystrokes in YUI3. Basically you will see few examples and a bunch of links to the <a title="YUI3 Official Documentation" href="http://developer.yahoo.com/yui/3/">YUI Library official documentation</a>.</p>
<p><strong>There are two different ways to define a keylistener in <a title="YUI Library Official Website" href="http://yuilibrary.com/projects/yui3/wiki">YUI3</a>:</strong></p>
<p>Considering that in YUI3 most of the DOM references are YUI Node objects, using the ‘on’ method for a node object is the most reasonable approach for all kind of listeners, including keylistener.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;node&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Y.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#my-input-element'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;keypress&quot;</span><span style="color: #339933;">,</span>  <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'keypress when the focus is on the input element'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We can use ‘keydown’ or ‘keyup’ to be more specific in the definition.</p>
<p><a title="YUI3 Docs" href="http://developer.yahoo.com/yui/3/api/Node.html#method_on">http://developer.yahoo.com/yui/3/api/Node.html#method_on</a></p>
<p>Also, we can use the traditional way:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Y.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'keydown'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'keydown when the focus is on the input element'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#my-input-element'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>or we can use the event name &#8216;key&#8217; and using the 4th argument to be more specific in the event definition, check this example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Y.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'key'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'keydown when the focus is on the input element'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#my-input-element'</span><span style="color: #339933;">,</span>  <span style="color: #3366CC;">'down'</span><span style="color: #339933;">,</span> Y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a title="YUI3 Docs" href="http://developer.yahoo.com/yui/3/api/YUI.html#method_on">http://developer.yahoo.com/yui/3/api/YUI.html#method_on</a></p>
<p>We can also use [press] or [up], or we can be even more specific describing which key combination we want to listen for, like this combination: [press:65,66+shift+ctrl], this event definition will fire only if keyCode 65 or 66 is detected during a keypress event while shift and control are held down.</p>
<p>Check this advanced example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Y.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'key'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #339933;">,</span> myInt<span style="color: #339933;">,</span> myString<span style="color: #339933;">,</span> myArray<span style="color: #339933;">,</span> myObj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'keydown when the focus is on the input element'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#my-input-element'</span><span style="color: #339933;">,</span>  <span style="color: #3366CC;">'down:65,12,13+shift'</span><span style="color: #339933;">,</span> Y<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'2'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>3<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>indx<span style="color: #339933;">:</span>4<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In this example, we have a definition for keydown for keyCodes 65, 12 or 13, plus the shift key held down at the same time. The 5th argument represents the execution context (Y), and the rest of the arguments will be passed thru the handler method. More information about this feature here:</p>
<p><a title="YUI3 Events" href="http://developer.yahoo.com/yui/3/event/#keylistener">http://developer.yahoo.com/yui/3/event/#keylistener</a></p>
<p>Of course, we can add this kind of event to any DOM element/tag, but it only makes sense if the event can get the focus, usually all kind of form input fields, anchors, images, buttons, etc.</p>
<p><strong>Controlling the event propagation and the default behavior:</strong></p>
<p>YUI3 controls all the events in the same way, wrapping the event object (variable ‘e’ passed thru the handler function) into a more consistent object. This feature allows us to control the object propagation easily. We can use preventDefault and stopPropagation directly, instead of invoking YAHOO.util.Event.stopPropagation or YAHOO.util.Event.preventDefault as we used to do in YUI2.x. Here is a very simple example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;node&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Y.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#my-input-element'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;keyup&quot;</span><span style="color: #339933;">,</span>  <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'the input element never receives this event.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a title="YUI3 Docs" href="http://developer.yahoo.com/yui/3/api/Event.Facade.html#method_preventDefault">http://developer.yahoo.com/yui/3/api/Event.Facade.html#method_preventDefault</a></p>
<p><strong>Global keystroke events:</strong></p>
<p>We can also listen for global events. Defining a listener for an especial element called ‘document‘, we will receive a notification for every keystroke.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;node&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Y.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'document'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;keyup&quot;</span><span style="color: #339933;">,</span>  <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'global keyup'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a title="YUI3 Docs" href="http://developer.yahoo.com/yui/3/api/Node.html#method_Y.get">http://developer.yahoo.com/yui/3/api/Node.html#method_Y.get</a></p>
<p><strong>Simulating keystroke events:</strong></p>
<p>Another feature, and this one is new in YUI3, is the event simulation, which means you can simulate user actions like clicks and keystrokes. I hope you don’t need to use it, because I really think that with a good design you don’t need to use this feature other than in a js unit test, but just in case, here is an example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;event-simulate&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> element <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;custom-input-element&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">//simulate a keystroke with Ctrl key down</span>
	Y.<span style="color: #660066;">Event</span>.<span style="color: #660066;">simulate</span><span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;keyup&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> keyCode<span style="color: #339933;">:</span> 65<span style="color: #339933;">,</span> ctrlKey<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a title="YUI3 Docs" href="http://developer.yahoo.com/yui/3/api/Event.html#method_simulate">http://developer.yahoo.com/yui/3/api/Event.html#method_simulate</a></p>
<p><strong>Examples:</strong></p>
<p><a title="YUI3 Key listeners - example" href="http://bubbling-library.com/sandbox/yui3/keystrokes.html">Click here to see a very simple sample of how to use all these concepts.</a></p>
<p><em><small>One final note: some of these concepts can change in the future (examples based on YUI3 PR2).</small></em></p>
]]></content:encoded>
			<wfw:commentRss>http://caridy.name/2009/03/yui3-keystroke-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The future of Bubbling Library YUI Extension</title>
		<link>http://caridy.name/2009/02/the-future-of-bubbling-library-yui-extension/</link>
		<comments>http://caridy.name/2009/02/the-future-of-bubbling-library-yui-extension/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 01:53:14 +0000</pubDate>
		<dc:creator>caridy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bubbling]]></category>
		<category><![CDATA[dispatcher]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[roadmap]]></category>
		<category><![CDATA[yregions]]></category>
		<category><![CDATA[yui]]></category>
		<category><![CDATA[yui3]]></category>

		<guid isPermaLink="false">http://blog.comarq.com/?p=16</guid>
		<description><![CDATA[I will continue supporting and developing the Bubbling Library YUI Extension. Considering that I don&#8217;t have too much time these days (working as YUI Contributor, pushing my new project called YRegions that should go public early this year, and my fulltime job at Yahoo!), I decided to support Bubbling 2.x for a while without any [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://bubbling-library.com/"><img class="alignright" style="border: 1px solid #cccccc; padding: 2px;margin-right: 0pt; margin-left: 10px;" title="Bubbling Library YUI Extension" src="http://bubbling-library.com/themes/bubbling/images/logo.gif" alt="" width="290" height="85" /></a>I will continue supporting and developing the <a href="http://bubbling-library.com/">Bubbling Library YUI Extension</a>. Considering that I don&#8217;t have too much time these days (working as <a title="YUI Community and Contributions" href="http://developer.yahoo.com/yui/community/">YUI Contributor</a>, pushing my new project called YRegions that should go public early this year, and my fulltime job at Yahoo!), I decided to support Bubbling 2.x for a while without any new widget/control/utility (to support <a title="YUI Library" href="http://developer.yahoo.com/yui/">YUI 2.x</a> updates), and I will wait until the release of YRegions 1.0 to continue the development of Bubbling 3.x on top of <a href="http://developer.yahoo.com/yui/3/">YUI 3.x</a>.</p>
<p>Also, considering the momentum of the <a href="http://bubbling-library.com/eng/api/docs/plugins/dispatcher">YUI Dispatcher Plugin</a>, and the number of requests, I&#8217;m writing the new version of the dispatcher as an stand alone plugin for <a href="http://developer.yahoo.com/yui/3/">YUI 3.x</a>. This new plugin should be ready in the next few weeks.</p>
<p>I apologize for the delay between the bubbling 1.5 and 2.x, and specially because of the official examples list (still working on it), but now I&#8217;m on the right track again.</p>
<p>The source code and the examples are now on <a href="http://github.com">GitHub</a>. Feel free to pull the source from <a title="Bubbling Library Source Code at GitHub" href="http://github.com/caridy/">Git</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://caridy.name/2009/02/the-future-of-bubbling-library-yui-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting Point</title>
		<link>http://caridy.name/2008/11/starting-point/</link>
		<comments>http://caridy.name/2008/11/starting-point/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 01:27:54 +0000</pubDate>
		<dc:creator>caridy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[introduction]]></category>

		<guid isPermaLink="false">http://blog.comarq.com/?p=5</guid>
		<description><![CDATA[Few months ago I decided to start a very technical blog, targeting the frontend developers community, and mainly those developers that use YUI Library, the bubbling library extension or Javascript in general.
Unfortunately I was unable to do it during 2008, I moved up to Miami, I got a full time job at Yahoo!, which required [...]]]></description>
			<content:encoded><![CDATA[<p>Few months ago I decided to start a very technical blog, targeting the frontend developers community, and mainly those developers that use <a href="http://developer.yahoo.com/yui">YUI Library</a>, the <a title="Bubbling Library YUI Extension" href="http://bubbling-library.com">bubbling library extension</a> or Javascript in general.</p>
<p>Unfortunately I was unable to do it during 2008, I moved up to Miami, I got a full time job at Yahoo!, which required time to get up to speed.</p>
<p>Now that everything is back to normally, I want to start blogging here. Also I want to keep blogging at <a title="YUI Library Blog" href="http://yuiblog.com">YUIBlog.com</a> from time to time, specially for long post related with the YUI.</p>
<p>The plan is to post twice a week, let&#8217;s see what comes.</p>
]]></content:encoded>
			<wfw:commentRss>http://caridy.name/2008/11/starting-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
