<?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; Json</title>
	<atom:link href="http://youngdutchdesign.com/tag/json/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 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>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>
