<?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>Blog::Log &#187; yui</title>
	<atom:link href="http://www.stpe.se/tag/yui/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stpe.se</link>
	<description>Not a blog, more a log.</description>
	<lastBuildDate>Wed, 02 Jun 2010 13:01:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Get selected value of radio button using YUI 3</title>
		<link>http://www.stpe.se/2009/12/selected-value-radio-button-yui-javascript/</link>
		<comments>http://www.stpe.se/2009/12/selected-value-radio-button-yui-javascript/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 10:31:26 +0000</pubDate>
		<dc:creator>stefan</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://www.stpe.se/?p=170</guid>
		<description><![CDATA[Getting the value of a the currently selected radio button may be done in a couple of ways. This is one approach using YUI 3. Here is the HTML: &#60;input type=&#34;radio&#34; name=&#34;myoptions&#34; value=&#34;one&#34;&#62; First &#60;input type=&#34;radio&#34; name=&#34;myoptions&#34; value=&#34;two&#34;&#62; Second &#60;input type=&#34;radio&#34; name=&#34;myoptions&#34; value=&#34;three&#34;&#62; Third Get the currently selected value using only one line of code: [...]]]></description>
			<content:encoded><![CDATA[<p>Getting the value of a the currently selected radio button may be done in a couple of ways. This is one approach using <a href="http://developer.yahoo.com/yui/3/">YUI 3</a>.</p>
<p>Here is the HTML:</p>
<pre class="brush: xml;">
&lt;input type=&quot;radio&quot; name=&quot;myoptions&quot; value=&quot;one&quot;&gt; First
&lt;input type=&quot;radio&quot; name=&quot;myoptions&quot; value=&quot;two&quot;&gt; Second
&lt;input type=&quot;radio&quot; name=&quot;myoptions&quot; value=&quot;three&quot;&gt; Third
</pre>
<p>Get the currently selected value using only one line of code:</p>
<pre class="brush: jscript;">
var value = Y.one('[name=myoptions]:checked').get('value');
</pre>
<p>Unfortunately, this does not work in Internet Explorer, so another (not as tight) approach is:</p>
<pre class="brush: jscript;">
function getRadioSelectedValue(selector) {
    var tmpValue= false;
    Y.all(selector).each(function(node) {
        if (node.get('checked') tmpValue = node.get('value');
    });
    return tmpValue;
}
var value = getRadioSelectedValue('.myRadioGroupClass'); // this assumes you've set appropriate class to radio elements
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stpe.se/2009/12/selected-value-radio-button-yui-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom Modules in YUI 3</title>
		<link>http://www.stpe.se/2009/11/custom-modules-in-yui-3/</link>
		<comments>http://www.stpe.se/2009/11/custom-modules-in-yui-3/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 21:21:45 +0000</pubDate>
		<dc:creator>stefan</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://www.stpe.se/?p=163</guid>
		<description><![CDATA[YUI 3 uses modules to group functionality and to only load what is used. This post describes how to create custom modules. The typical way modules are used is within the use() statement: YUI().use('node', 'event', function(Y) { // your stuff here }); In the above example the modules node and event are loaded. Let&#8217;s see [...]]]></description>
			<content:encoded><![CDATA[<p>YUI 3 uses modules to group functionality and to only load what is used. This post describes how to create custom modules.</p>
<p>The typical way modules are used is within the use() statement:</p>
<pre class="brush: jscript;">
YUI().use('node', 'event', function(Y) {
    // your stuff here
});
</pre>
<p>In the above example the modules <strong>node</strong> and <strong>event</strong> are loaded. Let&#8217;s see how custom modules may be included in the same way.</p>
<p>To define a new module the add() statement is used (note that it is a class and not instance method of the YUI object):</p>
<pre class="brush: jscript;">
YUI.add('my_module', function(Y) {
    Y.myFunction = function() {
        var privateFunc = function() {
            // ...
        };

        return {
            publicFunc: function() {
                // ...
            }
        }
    }();
}, '0.0.1', { requires: ['node'] });
</pre>
<p>A common way to share functionality among different YUI instances is to use the YUI namespace when assigning the function. If you do not recognize the structure of the above function definition you may find out more by reading about the <a href="http://yuiblog.com/blog/2007/06/12/module-pattern/">module pattern</a>.</p>
<p>If the file containing the custom module code is loaded, the custom module may be used in any use() statements as normal YUI modules, i.e. use(&#8216;my_module&#8217;, &#8230;).</p>
<p>To leverage the power of the <a href="http://developer.yahoo.com/yui/3/examples/yui/yui-loader-ext.html">YUI loader</a> to dynamically load the custom module a configuration object may be created.</p>
<pre class="brush: jscript;">
YUI({
    modules: {
       'my_module': {
           fullpath: &amp;quot;http://mydomain.com/js/my_module.js&amp;quot;,
           requires: ['node']
       }
    }
}).use('node', 'my_module, function(Y) {
    // access functionality of custom module
    Y.myFunction.publicFunc();
});
</pre>
<p>One thing to note is that YUI currently only makes one request to fetch dependencies. That is why the module&#8217;s <i>requires</i> array must be specified in the configuration object as well, in addition to what is in the last parameter of the add() statement.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stpe.se/2009/11/custom-modules-in-yui-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instance and class based plugins in YUI 3</title>
		<link>http://www.stpe.se/2009/11/instance-and-class-plugins-in-yui3/</link>
		<comments>http://www.stpe.se/2009/11/instance-and-class-plugins-in-yui3/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 04:56:59 +0000</pubDate>
		<dc:creator>stefan</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://www.stpe.se/?p=155</guid>
		<description><![CDATA[Using plugins in YUI 3 is a way to add functionality to existing objects in YUI (very much like you would use prototype to augment a function to a normal JavaScript object). Objects in YUI all derive from Y.Base. Note that this post is about YUI 3 and not YUI 2. However, the current YUI [...]]]></description>
			<content:encoded><![CDATA[<p>Using plugins in YUI 3 is a  way to add functionality to existing objects in YUI (very much like you would use prototype to augment a function to a normal JavaScript object). Objects in YUI all derive from <code>Y.Base</code>. </p>
<p>Note that this post is about YUI 3 and not YUI 2.</p>
<p>However, the <a href="http://developer.yahoo.com/yui/3/plugin/">current YUI 3 documentation</a> does really only get into how to add a plugin to a current instance. What about adding functionality to the class level so all instances of the same type of objects automatically get it?</p>
<p>First an example of how a simple plugin may look like:</p>
<pre class="brush: jscript;">
NodePlugin = function(config) {
    this._node = config.host;
}

NodePlugin.NS = 'vis';
NodePlugin.NAME = 'NodeVisibiltyPlugin';

NodePlugin.prototype = {
    show: function() {
        this._node.setStyle('display', 'block');
        return this_node;
    },

    hide: function() {
        this._node.setStyle('display', 'none');
        return this_node;
    }
};
</pre>
<p>What this plugin does it to add <code>hide()</code> and <code>show()</code> functions to the <code>vis</code> namespace (as specified in the code) of <code>Y.Node</code>.</p>
<p>This plugin would typically be used like this:</p>
<pre class="brush: jscript;">
var node = Y.one('#myElement');
node.plug(NodePlugin); // add plugin functionality
node.vis.hide();
</pre>
<p>If you would like to use the plugin functionality for all node objects it would be somewhat tedious to invoke <code>plug()</code> for each and every instance. The way to get around this, which is not really documented except in the <a href="http://developer.yahoo.com/yui/3/api/Plugin.Host.html#method_Plugin.Host.plug">API reference</a>, is to use the static method <code>Y.Plugin.Host.plug</code>.</p>
<pre class="brush: jscript;">
Y.Plugin.Host.plug(Y.Node, NodePlugin); // plug once ...

var node = Y.one('#myElement');
node.vis.hide(); // ... use anywhere
</pre>
<p>Now any new instances of <code>Y.node</code> have access to the plugin methods through the specified namespace. I also discovered that in order for this to work the static <code>NAME</code> property must be defined in the plugin object.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stpe.se/2009/11/instance-and-class-plugins-in-yui3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
