<?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>Young Dutch Design &#187; Mootools</title>
	<atom:link href="http://youngdutchdesign.com/category/mootools/feed" rel="self" type="application/rss+xml" />
	<link>http://youngdutchdesign.com</link>
	<description>Young Dutch Design is a new platform for young designers with frequently new added postings about productdesign, webdesign and other related subjects.</description>
	<lastBuildDate>Tue, 14 Jun 2011 20:25:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Mootools Widget Interface Demo</title>
		<link>http://youngdutchdesign.com/mootools-widget-interface-demo</link>
		<comments>http://youngdutchdesign.com/mootools-widget-interface-demo#comments</comments>
		<pubDate>Fri, 04 Feb 2011 07:00:33 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=3588</guid>
		<description><![CDATA[Everybody who&#8217;s working with WordPress knows the &#8216;widgetised&#8217; dashboard. A couple of weeks ago I wanted two lists to sort and also to drag one list item from one list to the other. I&#8217;ve searched over the internet to a nice plugin to do this. I discovered (maybe you guys are aware of this) that [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-4012" title="Screen shot 2011-02-03 at 22.08.11" src="http://youngdutchdesign.com/wp-content/uploads/2011/02/Screen-shot-2011-02-03-at-22.08.11--e1296767432388.png" alt="" width="300" height="216" />Everybody who&#8217;s working with WordPress knows the &#8216;widgetised&#8217; dashboard. A couple of weeks ago I wanted two lists to sort and also to drag one list item from one list to the other. I&#8217;ve searched over the internet to a nice plugin to do this. I discovered (maybe you guys are aware of this) that the default Sortable behavior of Mootools 1.2 is also to sort two list at a time.</p>
<p>I&#8217;ve made a simple example so you&#8217;ll see how it works. Read more about the set up in the full article.</p>
<p><a class="example_but demo" href="http://youngdutchdesign.com/examples/mootoolsWidgets.php">View example</a><br />
<span id="more-3588"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/mootools-widget-interface-demo/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mootools 1.2+ Drag.Cart Demo</title>
		<link>http://youngdutchdesign.com/mootools-1-2-drag-cart-demo</link>
		<comments>http://youngdutchdesign.com/mootools-1-2-drag-cart-demo#comments</comments>
		<pubDate>Wed, 02 Feb 2011 20:24:47 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Shopping basket]]></category>
		<category><![CDATA[XML / XHTML]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1762</guid>
		<description><![CDATA[I&#8217;ve searched on the internet for a good, simple and working example of the Drag.Cart plugin for Mootools 1.2+ but I haven&#8217;t found a single one. This is what I mean: the original Ghost Drag demo for Mootools 1.1. Here it is, a working example for Mootools 1.2+. Good luck and take a look at [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-3985" title="Screen shot 2011-02-02 at 21.14.17" src="http://youngdutchdesign.com/wp-content/uploads/2011/02/Screen-shot-2011-02-02-at-21.14.17--e1296677994504.png" alt="" width="300" height="210" />I&#8217;ve searched on the internet for a good, simple and working example of the Drag.Cart plugin for Mootools 1.2+ but I haven&#8217;t found a single one. This is what I mean: the original <a href="http://demos111.mootools.net/Drag.Cart" target="_blank">Ghost Drag demo</a> for Mootools 1.1.</p>
<p>Here it is, a working example for Mootools 1.2+. Good luck and take a look at the <a href="http://mootools.net/docs/more/Drag/Drag.Move" target="_blank">actual documentation</a> I&#8217;ve you need some more information.</p>
<p><a class="example_but demo" href="http://youngdutchdesign.com/examples/dragCart.php">View example</a><br />
<span id="more-1762"></span></p>
<h2>The html</h2>
<pre class="html">
<div id="items">
<div class="item" style="background-image: url(images/s1.jpg);">
		<span>Shirt 1</span></div>
<div class="item" style="background-image: url(images/s2.jpg);">
		<span>Shirt 2</span></div>
<div class="item" style="background-image: url(images/s3.jpg);">
		<span>Shirt 3</span></div>
<div class="item" style="background-image: url(images/s4.jpg);">
		<span>Shirt 4</span></div>
<div class="item" style="background-image: url(images/s5.jpg);">
		<span>Shirt 5</span></div>
<div class="item" style="background-image: url(images/s6.jpg);">
		<span>Shirt 6</span></div>
</div>
<div id="cart" class="cart">
<div class="info">Drag Items Here</div>
</div>
</pre>
<h2>CSS</h2>
<pre class="css">#items
{
	float: left;
	width: 525px;
	border: 1px solid #f9f9f9;
}

#cart
{
	float: right;
	width: 280px;
	background-color: #fff;
	border: 1px solid #f9f9f9;
	padding-bottom: 50px;
}

#cart .info
{
	color: #444;
	font-size: 0.9em;
	text-align: center;
	font-weight: bold;
}

.item {
	float: left;
	position: relative;
	width: 150px;
	height: 175px;
	border: 1px solid #eee;
	margin: 10px;
	border-right: 2px solid #ddd;
	border-bottom: 2px solid #ddd;
	background-color: #fff;
	background-position: left top;
	background-repeat: no-repeat;
	cursor: move;
}

#cart .item {
	width: 75px;
	height: 75px;
	margin: 5px;
	background-position: -40px -22px;
	border-width: 1px;
	cursor: default;
}

.item span {
	position: absolute;
	bottom: 0;
	left: 0;
	font-size: 0.8em;
	font-weight: bold;
	width: 100%;
	text-align: center;
}
</pre>
<h2>The Mootools</h2>
<p>Activate the mootools below after the DOM is ready&#8230;</p>
<pre class="javascript">var list = $$('.item');
var drop = $('cart');
var dropFx = new Fx.Morph('cart', {duration: 200, transition: Fx.Transitions.Sine.easeOut});

list.each(function(item){

	item.addEvent('mousedown', function(e){
		var e = new Event(e).stop();

		var clone = this.clone()
			.setStyles(this.getCoordinates())
			.setStyles({'opacity': 0.7, 'position': 'absolute'})
			.inject(document.body);

		var drag = new Drag.Move(clone, {
			droppables: '.cart',
			onDrop: function(element, droppable, event){
						drop.removeEvents();
						if(droppable){
							drop.highlight('#7389AE');
							dropFx.start({'background-color': '#FFFFFF'});

							item.clone().inject(drop);
							clone.dispose();
						}else{
							clone.dispose();
						}
					},
			onEnter: function(){
						dropFx.start({'background-color': '#98B5C1'});
					},
			onLeave: function(){
						dropFx.start({'background-color': '#FFFFFF'});
					}
		});

		drag.start(e); // start the event manual
	});
});
</pre>
<p><a class="example_but demo" href="http://youngdutchdesign.com/examples/dragCart.php">View example</a></p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/mootools-1-2-drag-cart-demo/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speeding up Mootools with createDocumentFragment()</title>
		<link>http://youngdutchdesign.com/speeding-up-mootools-with-createdocumentfragment</link>
		<comments>http://youngdutchdesign.com/speeding-up-mootools-with-createdocumentfragment#comments</comments>
		<pubDate>Tue, 30 Mar 2010 14:24:47 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=3479</guid>
		<description><![CDATA[A couple of days ago David Walsh posted a blog entry where he recommended a video from Google about JavaScript. I&#8217;ve found this very interesting and I have done some research about how to implement this very easy to Mootools. There are a lot of do&#8217;s and dont&#8217;s  but what is the best practice for [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago David Walsh posted a blog entry where he recommended a video from <a href="http://davidwalsh.name/javascript-speed" target="_blank">Google about JavaScript</a>. I&#8217;ve found this very interesting and I have done some research about how to implement this very easy to Mootools. There are a lot of do&#8217;s and dont&#8217;s  but what is the best practice for us as a Mootools developer? How to avoid the basic Mootools solutions and speed up your plugins? Well, I&#8217;ll post my neat workarounds to get your speed up.</p>
<p>I&#8217;ll start with modifying the DOM by injecting elements with the Mootools function inject(). Injecting elements to the DOM is very common with Mootools but it will make it slow down. To speed up you&#8217;ll have to do as little DOM modification as possible.</p>
<p>For example you load a JSON file and add elements depending on the content of the request. In this example we don&#8217;t avoid the Mootools each() function. We focus on the point that we don&#8217;t call the inject() function every time. This is my solution.<span id="more-3479"></span>Add the following lines to you general JavaScript file to implement a new function. I&#8217;ll recommend this if you</p>
<pre class="javascript">window.addEvent('domready', function() {
	Element.implement({
		docFragment: function(){
			return document.createDocumentFragment();
		}
	});
});
</pre>
<p>We&#8217;re going to add options to a select element, based on the JSON request.</p>
<pre class="javascript">var fragment = Element.docFragment();

json.each(function(o){
	var option = new Element('option',{'value': o.value, 'html': o.html});
	fragment.appendChild(option); //No reflow
});

$('select').appendChild(fragment); //Reflow!
</pre>
<h2>Results</h2>
<p>I&#8217;ve done some testing and I think it helped me pretty good to speed up my scripts. I&#8217;ve modified my <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class</a> and did some testing with it. Here are the results. Not very impressive at this point but you can see it will help the performance.</p>
<p><img class="alignnone size-full wp-image-3493" title="benchemark" src="http://youngdutchdesign.com/wp-content/uploads/2010/03/benchemark-e1269958736864.png" alt="" width="600" height="314" /></p>
<p>The test handles a 12 lined JSON request and for each record an option element will be added to the DOM. Not a very big effort for a browser, but you&#8217;ll see that there is some difference on the most common browsers and it&#8217;s no surprise that IE is the slowest of them all. If you scale this up it has to be a large difference and I&#8217;m confident with that.</p>
<p>Read more about <a href="https://developer.mozilla.org/En/DOM/Document.createDocumentFragment" target="_blank">createDocumentFragment</a> on Mozilla Developer Center.</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/speeding-up-mootools-with-createdocumentfragment/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>cvLinkSelect class v1.3 released!</title>
		<link>http://youngdutchdesign.com/cvlinkselect-class-v1-3-released</link>
		<comments>http://youngdutchdesign.com/cvlinkselect-class-v1-3-released#comments</comments>
		<pubDate>Wed, 24 Feb 2010 21:34:12 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[cvLinkSelect]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=3357</guid>
		<description><![CDATA[The last week I&#8217;ve completed the development of the cvLinkSelect class. I&#8217;ve added the option to disable the select elements that are not active because the previous values are not set. This is great feedback for the user! Check the updated page for the cvLinkSelect class! I&#8217;m searching for a easy way to style the [...]]]></description>
			<content:encoded><![CDATA[<p>The last week I&#8217;ve completed the development of the <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class</a>. I&#8217;ve added the option to disable the select elements that are not active because the previous values are not set. This is great feedback for the user!</p>
<p>Check the updated page for the <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class</a>!</p>
<p>I&#8217;m searching for a easy way to style the select elements to a custum layout just like the <a href="http://theuiguy.blogspot.com/2008/09/ultimate-dropdowns-v10.html" target="_blank">Select Box Factory</a> or something like that. Also I&#8217;m going to figure out if this class is usefull with a multiple select box. Anyway, I&#8217;m finished with this for the moment!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/cvlinkselect-class-v1-3-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Php part for cvLinkSelect class</title>
		<link>http://youngdutchdesign.com/php-part-for-cvlinkselect-class</link>
		<comments>http://youngdutchdesign.com/php-part-for-cvlinkselect-class#comments</comments>
		<pubDate>Sat, 20 Feb 2010 17:57:11 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[cvLinkSelect]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=3315</guid>
		<description><![CDATA[I&#8217;m very happy that a lot of developers have found my cvLinkSelect class and found it useful. cvLinkSelect is a simple Mootools 1.2 class that links form select elements based on the previous value via JSON requests. The php part was very basic though and a visitor pointed me to write the php part better, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://youngdutchdesign.com/examples/cvlinkselect.php"><img class="alignright size-full wp-image-3334" title="cvLinkSelect Example" src="http://youngdutchdesign.com/wp-content/uploads/2010/02/Screen-shot-2010-02-20-at-19.34.57-.png" alt="" width="253" height="135" /></a>I&#8217;m very happy that a lot of developers have found my <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class</a> and found it useful. cvLinkSelect is a simple Mootools 1.2 class that links form select elements based on the previous value via JSON requests. The php part was very basic though and a visitor pointed me to write the php part better, shorter and more functional. And here we are, just a simple 10 line php function.</p>
<p>In most cases you&#8217;ll get the data from a SQL database or something like that and in therefore it&#8217;s an array.</p>
<pre class="php">/* $arr = array from the database */
$arr = array(//array(id,name),
			 	array(15,'15 inch'),
				array(17,'17 inch'),
				array(19,'19 inch')
			);</pre>
<p><span id="more-3315"></span>Make sure that the you&#8217;ll only get the id and the name or another identifier. The total has to be two otherwise it don&#8217;t work.</p>
<p>To get the JSON request in the right format I&#8217;ve written a small function that will add the <strong>value</strong> and <strong>html</strong> key to the arrays.</p>
<pre class="php">/**
* Function to set the key for each value
* Requires: array(array())
* Returns: JSON format for cvLinkSelect class
*/
function json_cvLinkSelect($arr = array()){
	$json = array(); /* temporary array */

	foreach($arr as $ob){ /*walk trough the original array */
		$keys = array('value','html'); /*define the two keys */
		array_push($json,array_combine($keys,$ob)); /* push the new array to the temporary array, $json */
	}

	return json_encode($json); /* return the $json array */
}</pre>
<p>The output will be:</p>
<pre class="html">[{"value":"hard","html":"Hard"},{"value":"soft","html":"Soft"}]</pre>
<p>I&#8217;ve updated the zipfile with the working example if you guys need more info.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/php-part-for-cvlinkselect-class/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mootools 1.2 cvLinkSelect class 1.2</title>
		<link>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-2</link>
		<comments>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-2#comments</comments>
		<pubDate>Thu, 26 Nov 2009 20:46:01 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[XML / XHTML]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1765</guid>
		<description><![CDATA[I&#8217;ve updated the cvLinkSelect class. Some minor tweaks are added so you can control even more with the class. I hope you like it! Changes Maintain an empty element with a short discription and an empty value in your html page and the class will  not remove this one while you change the parent select [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated the cvLinkSelect class. Some minor tweaks are added so you can control even more with the class. I hope you like it!</p>
<h2>Changes</h2>
<ul>
<li> Maintain an empty element with a short discription and an empty value in your html page and the class will  not remove this one while you change the parent select box</li>
<li>Set the value of the first select box to the empty option after page reload</li>
<li>Comments added for developers and curious people</li>
<li>Updated the example</li>
<li>Removed some overhead in the class</li>
</ul>
<p>Go the the original page of the <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Done, but with errors on page</title>
		<link>http://youngdutchdesign.com/done-but-with-errors-on-page</link>
		<comments>http://youngdutchdesign.com/done-but-with-errors-on-page#comments</comments>
		<pubDate>Sat, 14 Nov 2009 15:03:14 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1743</guid>
		<description><![CDATA[Today while writing a new Mootools class an error occurred. Not a new one, I&#8217;ve had this one before. But how could this happen? Everything worked fine in Firefox en Firebug was very happy with my programming. No errors found. This is the moment the frustration grows. You place alerts on every line of code [...]]]></description>
			<content:encoded><![CDATA[<p>Today while writing a new Mootools class an error occurred. Not a new one, I&#8217;ve had this one before.</p>
<p><img class="alignnone size-full wp-image-1744" title="screenshot.192" src="http://youngdutchdesign.com/wp-content/uploads/2009/11/screenshot.192.jpeg" alt="screenshot.192" width="449" height="299" /></p>
<p>But how could this happen? Everything worked fine in Firefox en Firebug was very happy with my programming. No errors found.</p>
<p><span id="more-1743"></span>This is the moment the frustration grows. You place alerts on every line of code you can imagine and there&#8217;s still no solution for this error. Well, I can recommend you to watch the comma&#8217;s. Place no comma on the wrong place or on a place where you don&#8217;t need a comma. I&#8217;ve added a comma to the last option and this is where IE is going to throw stupid errors:</p>
<pre class="javascript">var cvMenu = new Class({
	Implements: [Options],

	options: {
		duration: 500,
		delay: 1500,
		transition: Fx.Transitions.Quad.easeInOut,
	},

	/* The rest of my class */

	lastFunction: function(){

		/* Last function in the class */

	},
}</pre>
<p>Has to be:</p>
<pre class="javascript">var cvMenu = new Class({
	Implements: [Options],

	options: {
		duration: 500,
		delay: 1500,
		transition: Fx.Transitions.Quad.easeInOut /* No comma here */
	},

	/* The rest of my class */

	lastFunction: function(){

		/* Last function in the class */

	} /* No comma here */
}</pre>
<p>Also becarefull at the end of your class, after the last function you may not use a comma!</p>
<p>IE is making life great hûh?</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/done-but-with-errors-on-page/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mootools 1.2 cvLinkSelect class 1.1</title>
		<link>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-1</link>
		<comments>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-1#comments</comments>
		<pubDate>Mon, 02 Nov 2009 06:48:04 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML / XHTML]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1708</guid>
		<description><![CDATA[Yesterday I&#8217;ve published the first version of the cvLinkSelect class for Mootools 1.2. Today I&#8217;ve released the new version of this nifty little class. I&#8217;ve completed the class with several finishing touches! View example Download file Changes Multiple GET variables in the request url. After a page refresh the script checks if the first linked [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1712" title="screenshot.185" src="http://youngdutchdesign.com/wp-content/uploads/2009/11/screenshot.185.jpeg" alt="screenshot.185" width="300" height="135" />Yesterday I&#8217;ve published the first version of the <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class for Mootools 1.2</a>. Today I&#8217;ve released the new version of this nifty little class. I&#8217;ve completed the class with several finishing touches!</p>
<p><a class="example_but demo" href="http://youngdutchdesign.com/examples/cvlinkselect1.1.php">View example</a> <a class="example_but download" href="http://youngdutchdesign.com/examples/js/cvLinkSelect1.1.js">Download file</a></p>
<h2>Changes</h2>
<ul>
<li>Multiple GET variables in the request url.</li>
<li>After a page refresh the script checks if the first linked selectbox option is not empty. If it isn&#8217;t empty the first request fires.</li>
<li>If the request is empty it&#8217;s the last item in the linked selectboxes range. In this case we have to fire the isLast function.</li>
</ul>
<p>Read more about the usage on the original post for the <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class</a>!</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mootools 1.2 cvLinkSelect class</title>
		<link>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class</link>
		<comments>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class#comments</comments>
		<pubDate>Sun, 01 Nov 2009 22:11:52 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[XML / XHTML]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1680</guid>
		<description><![CDATA[If you&#8217;re making a form with today&#8217;s standards you often have to make several select elements with the options of the next select elements referring to the previous one. It&#8217;s a simple task to create a small Mootool which do it for you but it&#8217;s always a time consuming process, especially if you&#8217;ll have a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1783" title="Screen shot 2009-11-26 at 21.09.16" src="http://youngdutchdesign.com/wp-content/uploads/2009/11/Screen-shot-2009-11-26-at-21.09.16-.png" alt="Screen shot 2009-11-26 at 21.09.16" width="299" height="127" />If you&#8217;re making a form with today&#8217;s standards you often have to make several select elements with the options of the next select elements referring to the previous one. It&#8217;s a simple task to create a small Mootool which do it for you but it&#8217;s always a time consuming process, especially if you&#8217;ll have a lot of select boxes. I thought that if I have use this functionality more than once a class would be helpful.</p>
<p>This class links the select boxes to each other. When you change the first select element the options for the following select boxes are loaded. Simple as that.</p>
<p><a class="example_but demo" href="http://youngdutchdesign.com/examples/cvlinkselect.php">View example</a> <a class="example_but download" href="http://youngdutchdesign.com/examples/js/cvLinkSelect.js">Download file</a> <a class="example_but zipfile" href="http://www.youngdutchdesign.com/downloads/cvLinkSelect_example.zip">Download Zip</a></p>
<p><span id="more-1680"></span></p>
<h2>The html</h2>
<p>Note that only the first select element has some options in it. These can be static html or generated by php.</p>
<pre class="html">
<select id="category" class="inputbox linked" name="category">
<option>-- Select the category --</option>
<option value="car">Car</option>
<option value="bicyle">Bicycle</option>
</select>
<select id="type" class="inputbox linked" name="type">
<option>-- Select the type --</option>
</select>
<select id="function" class="inputbox linked" name="function">
<option>-- Select the function --</option>
</select>
</pre>
<p><!--adsense--></p>
<h2>The css</h2>
<p>These css is only for the style of the form elements. Nothing special.</p>
<p>Do you need a neat little loading gif? Just go to <a href="http://www.ajaxload.info/" target="_blank">Ajaxload</a> and download your own!</p>
<pre class="css">.loading{
	background: url(images/loading.gif) 170px center no-repeat;
	}

.inputbox {
	width: 220px;
	padding: 5px;
	border:1px solid #EEE;
	font: 12px "Courier New", Courier, monospace;
	color: #333;
	}

select.inputbox {
	width: 232px;
	}</pre>
<h2>The javascript</h2>
<p>This is where the magic happens. Two variables are very important to make this class work.</p>
<ul>
<li><strong>value</strong>: This is the name of the object that is the value in the future option element</li>
<li><strong>option</strong>: This is the name of the object that is the visual value of in the option element</li>
</ul>
<pre class="javascript">window.addEvent('domready', function() {
	var l = new cvLinkSelect({
        select_class: '.linked', //the class for the linked select boxes
		url: 'yourajaxurl.php', //pad to ajax file
		multiple_var: true, //use multiple get variables or only one
		loadClass: 'loading', //the css class that is added when a request is made
		isLast: function(){
			alert('Last dynamic selectbox!');
		},
		hasnoSub: function(){
			alert('This option has no depending options. Lets hide the next elements!');

			l.select.each(function(s){
				if(l.select.indexOf(s) &gt;= l.select.indexOf(l.current)){ //if the select depends on the parent
					s.hide();
				}
			});
		},
		hasSub: function(){
			l.select.each(function(s){
				if(l.select.indexOf(s) &gt;= l.select.indexOf(l.current)){ //if the select depends on the parent
					s.show();
				}
			});
		}
	});
});</pre>
<h2>The JSON format</h2>
<p>You have to make sure that the AJAX request returns a JSON format that is formatted like the example below.</p>
<p><strong>NOTE</strong><br />
Be sure that the json always contains a value and a html object. See the demo for a example.</p>
<pre class="html">[{"value":"wheels","html":"Wheels"},
{"value":"body","html":"Body"},
{"value":"exaust","html":"Exaust"}]</pre>
<h2>The php</h2>
<p>The php file has to return a JSON formatted string depending on the selected value. You can use if-statements or use a switch method to print the exact output but the basics are just this:</p>
<pre class="php">if(isset($_GET['category'])){
	echo '[{"value":"wheels","html":"Wheels"},{"value":"body","html":"Body"}]';
}elseif(isset($_GET['type'])){
	echo '[{"value":15,"html":"15 inch"},{"value":17,"html":"17 inch"}]';
}</pre>
<p>When your website is dynamic you probably prefer to use a flexible way of presenting the JSON variable. <a href="http://youngdutchdesign.com/php-part-for-cvlinkselect-class">Read more about this in another article I&#8217;ve wrote</a>. I think it&#8217;s very useful so read it and don&#8217;t reinvent the wheel.</p>
<h2>Multiple GET variables</h2>
<p>In the old version we had only request with this kind of urls:</p>
<p style="padding-left: 30px;"><strong>ajax.php?category=var</strong></p>
<p>But in my opinion this wasn&#8217;t sufficient for the main goal: Get the right data in the select boxes and make programming easier. So that&#8217;s why I&#8217;ve made an update to the class so you can get this kind of requests:</p>
<p style="padding-left: 30px;"><strong>ajax.php?category=var&amp;type=var2</strong></p>
<p>These urls can be activated via the multiple_var option in the class. Before you use them: please make sure that your php script has the correct architecture. A <strong>very basic </strong>example:</p>
<pre class="php">if(!empty($_GET['category'])){
	if($_GET['category'] == 'car'){
		if(!empty($_GET['type'])){
			if($_GET['type'] == 'wheels'){
				/* return the wheels JSON variabele */
			}
		}else{
			/* return the car JSON variable */
		}
	}
}</pre>
<p>I hope you enjoy this class and if you have any questions or suggestions; please leave a comment!</p>
<h2>Changelog</h2>
<ul>
<li><strong>v1.4 30 mrt 2010</strong>
<ul>
<li>Fixed the weird Elements bug in Mootools 1.2.4</li>
<li>Upgraded the speed with document.createDocumentFragment()</li>
</ul>
</li>
<li><strong>V1.3 26 feb 2010</strong>
<ul>
<li>It&#8217;s possible to disable the select elements when no options are available. This is great feedback</li>
</ul>
</li>
<li><strong>V1.2.2 &#8211; 21 feb 2010</strong>
<ul>
<li>Fixed the reset bug. It will be resetting all the select elements if an empty value is set.</li>
</ul>
</li>
<li><strong>V1.2.1 &#8211; 20 feb 2010</strong>
<ul>
<li>Reset the depending select elements if when a user changes the upper select element</li>
</ul>
</li>
<li><strong>V1.2 &#8211; 26 nov 2009</strong>
<ul>
<li> Maintain an empty element with a short discription and an empty value in your html page and the class will  not remove this one while you change the parent select box</li>
<li>Set the value of the first select box to the empty option after page reload</li>
<li>Comments added for developers and curious people</li>
<li>Updated the example</li>
<li>Removed some overhead in the class</li>
</ul>
</li>
<li><strong>V1.1 &#8211; 2 nov 2009</strong>
<ul>
<li>Multiple GET variables in the request url.</li>
<li>If the request is empty it’s the last item in the linked selectboxes range. In this case we have to fire the isLast function.</li>
</ul>
</li>
<li><strong>V1.0 &#8211; 1 nov 2009</strong>
<ul>
<li>First release of the link select class</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class/feed</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>MooDrop: Mootools Eyedropper tool</title>
		<link>http://youngdutchdesign.com/moodrop-mootools-eyedropper-tool</link>
		<comments>http://youngdutchdesign.com/moodrop-mootools-eyedropper-tool#comments</comments>
		<pubDate>Thu, 24 Sep 2009 15:54:04 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1595</guid>
		<description><![CDATA[For a new application I&#8217;m working on I&#8217;ve searched the internet for a javascript based eyedropper tool. Fortunately I only found some Java based applications and I&#8217;m not a big fan of those. So I decided to write my own Eyedropper. Test it and install it on your own website! You can tweak some events [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1639" title="moodrop" src="http://youngdutchdesign.com/wp-content/uploads/2009/09/moodrop.jpg" alt="moodrop" width="200" height="200" />For a new application I&#8217;m working on I&#8217;ve searched the internet for a javascript based eyedropper tool. Fortunately I only found some Java based applications and I&#8217;m not a big fan of those.</p>
<p>So I decided to write my own Eyedropper. Test it and install it on your own website! You can tweak some events so it has more functionality.</p>
<p>There is also a Zip file available with a working example. Just upload the files to your folder on your webspace and navigate to it!</p>
<p><a class="example_but demo" href="http://youngdutchdesign.com/examples/moodrop.php">Example</a> <a class="example_but download" href="http://youngdutchdesign.com/examples/js/moodrop.js">Download Class</a> <a class="example_but zipfile" href="http://www.youngdutchdesign.com/downloads/cvMooDrop_examples.zip">Download Zip</a></p>
<p><span id="more-1595"></span></p>
<h2>File structure</h2>
<p>The following structure is used in the example and the documentation.</p>
<ul>
<li><strong>images</strong>
<ul>
<li>your_image.jpg</li>
</ul>
</li>
<li><strong>js</strong>
<ul>
<li>cvMooDrop.js</li>
<li>mootools-1.2.js</li>
</ul>
</li>
<li>ajax_moodrop.php</li>
<li>basic.css</li>
<li>cvMooDrop.css</li>
<li>index.php /*This file contains the html for the eyedropper*/</li>
<li>moodrop.php</li>
</ul>
<h2>The html</h2>
<p>The html is really simple. The path to the image is the relative path.</p>
<h2>The css</h2>
<pre class="css">#dropperid {
	float: left;
	padding: 0px;
	width: 551px; //the width of the image
	height: 157px; //the height of the image
	}

#prev {
	float: left;
	width: 80px;
	height: 80px;
	border: 1px #CCC solid;
	}</pre>
<h2>The basic javascript</h2>
<pre class="javascript">window.addEvent('domready', function() {
	var test1 = new moodrop('dropperid',{
		url: 'ajax_moodrop.php',
		prev_id: 'prev'
	});
});</pre>
<h2>The more advanced javascript</h2>
<pre class="javascript">window.addEvent('domready', function() {
	var test2 = new moodrop('dropperadvanced',{
		url: 'ajax_moodrop.php',
		prev_id: 'prev2',
	});

	var colors = [];

	var addColor = function(c){
		if(colors.contains(c)){
			alert('This color already exists!');
		}else{
			colors.push(c);
			$('colors_field').value = JSON.encode(colors);
			createColor(c);
		}
	}

	var createColor = function(c){
		var box = new Element('span',{	'id': this.hex,
							  			'class': 'box',
										'styles': {
											'background': c,
											'display': 'block',
											'float': 'left',
											'cursor': 'pointer'
											}
										}).inject($('scheme'));
	};

	$('add').addEvent('click',function(a){
		addColor(test2.hex);
	});
});</pre>
<h2>The php (ajax_moodrop.php)</h2>
<p>The AJAX request has several variables in it to get the right pixel, the pixel the dropper is pointing at.</p>
<ul>
<li><strong>image: </strong>the relative path to the image file</li>
<li><strong>n: </strong>the relative top position of the pixel</li>
<li><strong>w: </strong>the relative left position of the pixel</li>
</ul>
<pre class="php">if(isset($_GET['image'])){
	/* select the left lower pixel from the dropperdiv and get the color index */
	$im = imagecreatefromjpeg($_GET['image']);
	$color_index = imagecolorat($im, $_GET['w'], $_GET['n']);

	/* get rid of the temporary image and display the human readable hex color */
	echo '#'.dechex($color_index);
}</pre>
<p>The function imagecreatefrom* can be changed to several functions, depending on the image type you use. In this case I&#8217;ve used a very simple static solution but you can select the correct function by checking the mime type.</p>
<ul>
<li><a href="http://php.net/imagecreatefromjpeg" target="_blank">imagecreatefromjpeg</a></li>
<li><a href="http://php.net/imagecreatefromgif" target="_blank">imagecreatefromgif</a></li>
<li><a href="http://php.net/imagecreatefrompng" target="_blank">imagecreatefrompng</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/moodrop-mootools-eyedropper-tool/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
