<?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>trickeries! &#187; recursive</title>
	<atom:link href="http://trickeries.com/tag/recursive/feed/" rel="self" type="application/rss+xml" />
	<link>http://trickeries.com</link>
	<description>it's tricky to rock a style thats liked online</description>
	<lastBuildDate>Tue, 02 Mar 2010 06:01:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>rAccordion &#8211; a MooTools 1.2 recursive accordion</title>
		<link>http://trickeries.com/192/raccordion-a-mootools-12-recursive-accordion/</link>
		<comments>http://trickeries.com/192/raccordion-a-mootools-12-recursive-accordion/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 08:18:08 +0000</pubDate>
		<dc:creator>atom</dc:creator>
				<category><![CDATA[downloads]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[rAccordion]]></category>
		<category><![CDATA[recursive]]></category>

		<guid isPermaLink="false">http://trickeries.com/?p=192</guid>
		<description><![CDATA[So I have managed to create a recursive mootools accordion, which is something I have wanted to get done for a long time.
The secret ingredient to get this made up was some CSS3 selectors and a bit of recursion.
You basically just pass in a class for the toggles, a class for the elements, and a [...]]]></description>
			<content:encoded><![CDATA[<p>So I have managed to create a recursive mootools accordion, which is something I have wanted to get done for a long time.</p>
<p>The secret ingredient to get this made up was some CSS3 selectors and a bit of recursion.</p>
<p>You basically just pass in a class for the toggles, a class for the elements, and a parent container to reference.</p>
<p>The usage ends up fairly simple:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #FF00FF; font-weight: bold;">new</span> rAccordion<span style="color: #99FF00;">&#40;</span><span style="color: #3366CC;">'container'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'toggle'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'element'</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In the example, container is the id of the parent that the classes are in, toggle is the class that each toggle has, and element is the class that each element has.  A fourth argument can be passed, which is the options argument for the mootools Accordion class.</p>
<p>There are some kinks thatstill need working out.  There are inherit problems with just jamming accordions inside of each other.  The way mootools creates the accordion requires quite a bit of inline styles, which include defined heights.  These heights become problematic when accordions inside accordions need to expand or contract, but their parent element has a defined height and overflow which will not allow the newly expanded portion to be seen.</p>
<p>I do have something of a solution in place, but it feels a little hacky, but I am not sure it will get any better unless I rewrite the accordion.</p>
<p>If anyone has any ideas on how to address this issue, please drop me a comment.</p>
<h2><a href="http://trickeries.com/demo/rAccordion/">example</a></h2>
<h2><a href='http://trickeries.com/wp-content/uploads/2008/08/raccordion.zip'>download w/the example</a></h2>
<h2>Here is the class:</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #FF00FF; font-weight: bold;">var</span> rAccordion <span style="color: #339933;">=</span> <span style="color: #FF00FF; font-weight: bold;">new</span> <span style="color: #FF00FF; font-weight: bold;">Class</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#123;</span>
&nbsp;
	initialize<span style="color: #339933;">:</span> <span style="color: #FF00FF; font-weight: bold;">function</span><span style="color: #99FF00;">&#40;</span>container<span style="color: #339933;">,</span> toggleClass<span style="color: #339933;">,</span> elementClass<span style="color: #339933;">,</span> options<span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#123;</span>
		<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">container</span> <span style="color: #339933;">=</span> container<span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">tClass</span> <span style="color: #339933;">=</span> toggleClass<span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">eClass</span> <span style="color: #339933;">=</span> elementClass<span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">options</span> <span style="color: #339933;">=</span> options<span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">selector</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#'</span> <span style="color: #339933;">+</span> <span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">container</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' &gt; .'</span><span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">makeAccordion</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #99FF00;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	makeAccordion<span style="color: #339933;">:</span> <span style="color: #FF00FF; font-weight: bold;">function</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#123;</span>
		<span style="color: #FF00FF; font-weight: bold;">new</span> Accordion<span style="color: #99FF00;">&#40;</span>
			$$<span style="color: #99FF00;">&#40;</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">selector</span><span style="color: #339933;">+</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">tClass</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">,</span>
			$$<span style="color: #99FF00;">&#40;</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">selector</span><span style="color: #339933;">+</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">eClass</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">options</span>
		<span style="color: #99FF00;">&#41;</span>.<span style="color: #0066FF;">addEvents</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// The onActive and onComplete events added to the stack here to</span>
			<span style="color: #006600; font-style: italic;">// attempt to address some of the css issues.</span>
			<span style="color: #3366CC;">'onActive'</span><span style="color: #339933;">:</span> <span style="color: #FF00FF; font-weight: bold;">function</span><span style="color: #99FF00;">&#40;</span>toggle<span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#123;</span>
				<span style="color: #00FF00; font-weight: bold;">if</span><span style="color: #99FF00;">&#40;</span>toggle.<span style="color: #0066FF;">getParent</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span>.<span style="color: #0066FF;">getStyle</span><span style="color: #99FF00;">&#40;</span><span style="color: #3366CC;">'height'</span><span style="color: #99FF00;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #FFFF00;">0</span><span style="color: #99FF00;">&#41;</span>
					toggle.<span style="color: #0066FF;">getParent</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span>.<span style="color: #0066FF;">setStyle</span><span style="color: #99FF00;">&#40;</span><span style="color: #3366CC;">'height'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #99FF00;">&#125;</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">'onComplete'</span><span style="color: #339933;">:</span> <span style="color: #FF00FF; font-weight: bold;">function</span><span style="color: #99FF00;">&#40;</span>a<span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#123;</span>
				<span style="color: #00FF00; font-weight: bold;">if</span> <span style="color: #99FF00;">&#40;</span>$defined<span style="color: #99FF00;">&#40;</span>a<span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#41;</span> <span style="color: #99FF00;">&#123;</span>
					<span style="color: #FF00FF; font-weight: bold;">var</span> height <span style="color: #339933;">=</span> <span style="color: #FFFF00;">0</span><span style="color: #339933;">;</span>
					a.<span style="color: #0066FF;">getParent</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span>.<span style="color: #0066FF;">getChildren</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span>.<span style="color: #0066FF;">each</span><span style="color: #99FF00;">&#40;</span><span style="color: #FF00FF; font-weight: bold;">function</span><span style="color: #99FF00;">&#40;</span>e<span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#123;</span>
						height <span style="color: #339933;">=</span> height <span style="color: #339933;">+</span> e.<span style="color: #0066FF;">offsetHeight</span><span style="color: #339933;">;</span>
					<span style="color: #99FF00;">&#125;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #00FF00; font-weight: bold;">if</span><span style="color: #99FF00;">&#40;</span>height <span style="color: #339933;">!=</span> a.<span style="color: #0066FF;">getParent</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span>.<span style="color: #0066FF;">offsetHeight</span> <span style="color: #339933;">&amp;&amp;</span> a.<span style="color: #0066FF;">getParent</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span>.<span style="color: #0066FF;">offsetHeight</span> <span style="color: #339933;">!=</span> <span style="color: #FFFF00;">0</span><span style="color: #99FF00;">&#41;</span>
						a.<span style="color: #0066FF;">getParent</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span>.<span style="color: #0066FF;">setStyle</span><span style="color: #99FF00;">&#40;</span><span style="color: #3366CC;">'height'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #99FF00;">&#125;</span>
			<span style="color: #99FF00;">&#125;</span>
		<span style="color: #99FF00;">&#125;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">selector</span> <span style="color: #339933;">+=</span> <span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">eClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' &gt; .'</span><span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">if</span><span style="color: #99FF00;">&#40;</span>$defined<span style="color: #99FF00;">&#40;</span>$$<span style="color: #99FF00;">&#40;</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">selector</span><span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#91;</span><span style="color: #FFFF00;">0</span><span style="color: #99FF00;">&#93;</span><span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#41;</span>
			<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">makeAccordion</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #99FF00;">&#125;</span>
&nbsp;
<span style="color: #99FF00;">&#125;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://trickeries.com/192/raccordion-a-mootools-12-recursive-accordion/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>
