<?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>delusionworld blog &#187; progressive Enhancement</title>
	<atom:link href="http://www.delusionworld.com/tag/progressive-enhancement/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.delusionworld.com</link>
	<description>my MooTools, TYPO3 and FLOW3 experiences</description>
	<lastBuildDate>Fri, 24 Jun 2011 21:22:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>General MooTools UI</title>
		<link>http://www.delusionworld.com/mootools/general-mootools-ui/</link>
		<comments>http://www.delusionworld.com/mootools/general-mootools-ui/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 13:41:46 +0000</pubDate>
		<dc:creator>daKmoR</dc:creator>
				<category><![CDATA[MooTools]]></category>
		<category><![CDATA[progressive Enhancement]]></category>
		<category><![CDATA[Repository]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.delusionworld.com/?p=65</guid>
		<description><![CDATA[While I was trying to fully utilize progressive Enhancement I had another idea. Why not separate functionality and layout even while writing javascript/MooTools. That way it would be far easier to create different layouts for the same functionality without the need to reproduce code. Again let&#8217;s just look at an example: simple tabs (my favorite [...]]]></description>
			<content:encoded><![CDATA[<p>While I was trying to fully utilize progressive Enhancement I had another idea. Why not <strong>separate functionality and layout</strong> even while writing javascript/MooTools. That way it would be far easier to <strong>create different layouts for the same functionality</strong> without the need to reproduce code. Again let&#8217;s just look at an example:<br />
<a href="http://www.delusionworld.com/files/general-mootools-ui/mootools-tabs.html">simple tabs</a> (my favorite example&#8230; :p)</p>
<pre class="brush: jscript; title: ;">
var myTabs = new FlowTabs.inline( $$('.FlowTabs &gt; h4'), $$('.FlowTabs &gt; div') );
</pre>
<p><em>If you look at the source you will find an &#8220;$require(&#8230;);&#8221; it&#8217;s just the same as including the file directly with script or link tag.</em> You can find more info about that in my previous posts about MPR. So what do we get with this code &#8211; <strong>It just gives us the functionality</strong> and looks pretty shitty, as only the necessary things are defined. Now let&#8217;s take at an example where we use the UI. <a href="http://www.delusionworld.com/files/general-mootools-ui/mootools-ui-tabs.html">simple ui tabs</a></p>
<pre class="brush: jscript; title: ;">
UI.render('Plain');
</pre>
<p>So it looks now a little bit nicer, but that can all be done with CSS &#8211; and you are right as if we look at the source of the UI.Plain.Tabs it does nothing &#8211; it <strong>just includes 2 css files</strong>&#8230;.</p>
<pre class="brush: jscript; title: ;">
$require(MPR.path + 'Ui/Plain/Plain.js');

$require(MPR.path + 'Snippets/Css/Resources/clearfix.css');
$require(MPR.path + 'Ui/Plain/Resources/Plain.Tabs.css');

Ui.Plain.Tabs = new Class({
	Implements: [Options],
	options: {
	},

	initialize: function(options) {
		this.setOptions(options);
	}
});
</pre>
<p>How boring is that?!?! Seems like we <strong>need a little more complicated example</strong>. I guess most of you know the MochaUI &#8211; how about adopting some style from it&#8230;</p>
<h2>MochaUI Tabs</h2>
<p><a href="http://www.delusionworld.com/files/general-mootools-ui/mootools-ui-tabs-mocha.html">mocha ui tabs</a></p>
<pre class="brush: jscript; title: ;">
$require(MPR.path + 'Ui/Mocha/Mocha.Tabs.js');
UI.render('Mocha');
</pre>
<p>only those 2 lines changed &#8211; we now load a different UI class and render a different theme called &#8216;Mocha&#8217;&#8230; so let&#8217;s look at it&#8217;s functions</p>
<pre class="brush: jscript; title: ;">
initialize: function(tabs, options) {
	this.setOptions(options);
	this.attach(tabs);
},

attach: function(tabs) {
	if ( $type(tabs) == 'string' ) tabs = $$(tabs);
	if ( $type(tabs) == 'element' ) tabs = [tabs];

	tabs.each( function(el) {
		var inside = new Element('span', { html: el.get('html') } );
		el.empty();
		el.grab(inside);
	}, this);
}
</pre>
<p>It&#8217;s again not really funny as it <strong>just creates an span inside every tab</strong> &#8211; we could have easily put this inside the &#8220;original&#8221; Tab Class. However what if the<strong> problem is a little bit more complex</strong> and the <strong>layout is also quite heavy on it&#8217;s own</strong>. Wouldn&#8217;t it be nice to separate these problems&#8230; Yeah I guess with just words you won&#8217;t believe me. So I will show you something more complex afterward.<br />
But for now <strong>let&#8217;s find out how the UI knows what theme to render and with which parameters</strong>. For that we need to look at the FlowTabs.inline.js file&#8230; at the bottom you will find:</p>
<pre class="brush: jscript; title: ;">
if ( typeof(UI) !== 'undefined' ) UI.registerClass({ 'Tabs': { 'param': '.ui-tab', 'name': 'FlowTabs.inline' } });
</pre>
<p>So what this does is basically it <strong>registers the FlowTabs Class as a Tabs Class</strong> with it&#8217;s default parameter and it&#8217;s name&#8230; Now when the UI is rendered it calls UI.<em>theme</em>.Tabs(<em>param</em>) and that&#8217;s exactly what we created earlier: &#8220;Ui.Mocha.Tabs = new Class({&#8221;</p>
<p>So let&#8217;s <strong>summaries this a little</strong>&#8230; until now it works like:</p>
<ul>
<li>create all Tabs + Content</li>
<li>call the UI Class that will look for predefined classes and it will modify the layout accordingly</li>
</ul>
<p>That&#8217;s pretty straight forward and in many situations this will work pretty well. <strong>However what about dynamically created tabs</strong> after the initial creation. I don&#8217;t know maybe loading with ajax or as a user populates some fields&#8230; So my FlowTabs class my support creating these Tabs on the fly but I somehow need to tell the UI that new Tabs are created and they need to be styled.</p>
<p>So now how do we do that:<br />
FlowTabs.inline.js in the attach function (creating of the tabs) we just fire an Event and give it some things to work with:</p>
<pre class="brush: jscript; title: ;">
this.fireEvent('onUiAttach', [el, j-1, content[i], this.tabsContainer]);
</pre>
<p>now what we need to do is use this onUiAttach Event. For that we just define this.options.refactor</p>
<pre class="brush: jscript; title: ;">
Ui.Mocha.Tabs = new Class({
	Implements: [Options],
	options: {
		refactor: {
			options: {
				onUiAttach: function(el, i) {
					if ( (typeof(UI) !== 'undefined') &amp;&amp; ( typeof(UI.Uis.Tabs) !== 'undefined' ) ) {
						UI.Uis.Tabs.attach( $(el) );
					}
				}
			}
		}
	},
</pre>
<p>If this is provided the <strong>UI will either refactor the class</strong> (if it hasn&#8217;t been instantiated) or it <strong>will set it options</strong> if the class has already been instantiated. [This doesn't seem to work currently - so note at the end]  To detect that we have another function in FlowTabs.inline that will be called on initialize:</p>
<pre class="brush: jscript; title: ;">
registerUi: function() {
	if ( typeof(UI) !== 'undefined' )
		UI.registerClass({ 'Tabs': { 'param': '.' + this.options.ui.tab['class'], 'name': 'FlowTabs.inline', 'class': this } });
}
</pre>
<p>it&#8217;s <strong>basically the same as the registration above</strong>, only that we now get the param from the option &#8211; this will help for example if we want to change the classes of the tabs; with that we don&#8217;t need to change them on the Tab creation script and on the Tab UI script&#8230; it will be automatically updated on the UI script. <strong>And we give the ui as &#8216;class&#8217; this</strong> (that&#8217;s pretty important!).</p>
<p>So now with all that it doesn&#8217;t matter when the UI [UI.render('Mocha');] is called as:</p>
<ul>
<li>If you call it at the beginning before all the tabs are created it basically does nothing except that it refactors every Class that it might need. So these classes then automatically do the right thing when the Event onUiAttach is fired.</li>
<li>If you call it at the end it will create all the necessary layout and set the options for every Class that&#8217;s registered so further elements that get attached get the layout automatically.</li>
</ul>
<p>I still prefer to call the UI at the and as it might need a little bit less performance. [so also note at the end]</p>
<h2>FlowWindows</h2>
<p>So now <strong>let&#8217;s go for an more complex example</strong>. Let&#8217;s talk about windows&#8230; I think there are quite a few implementations out there&#8230; MochaUI for example &#8211; it&#8217;s Window Class is really cool. However it&#8217;s also really really big. So what if I just want a little div to resize and drag around. <strong>I think functionality and UI should be separated</strong>. I mean now I needed to write my own class as I didn&#8217;t &#8220;wanted&#8221; to use a complex layout as MochaUI&#8230;. the functionality would be great but <strong>you can&#8217;t get MochaUI Window without the Layout</strong>&#8230;<br />
So basically that&#8217;s what I came up: <a href="http://www.delusionworld.com/files/general-mootools-ui/mootools-windows.html">simple windows</a>. (I looked up some things at MochaUI window so it wasn&#8217;t that hard&#8230; :p)</p>
<p>If you look at it you see:</p>
<pre class="brush: jscript; title: ;">
$require(MPR.path + 'Windows/FlowWindows/FlowWindows.js');
[...]
var myWindows = new FlowWindows( $$('.FlowWindow &gt; h3')[0], $$('.FlowWindow &gt; div')[0] );
myWindows.attach( $$('.FlowWindow &gt; h3')[0], $$('.FlowWindow &gt; div')[0] );
</pre>
<p>So this just creates all the divs needed for all the handlers to resize, the header, the controlls&#8230; <strong>all you need for a nice window</strong>&#8230; but it&#8217;s ugly. yeah sure it&#8217;s<strong> just for functionality</strong> no UI at all. Now let&#8217;s get some UI &#8211; <a href="http://www.delusionworld.com/files/general-mootools-ui/mootools-ui-windows.html">the plain UI</a> is not really something special (again no change with js &#8211; just css). To use it &#8211; there are just some small differences&#8230;</p>
<pre class="brush: jscript; title: ;">
$require(MPR.path + 'Ui/Plain/Plain.Full.js');
[...]
UI.render('Plain');
</pre>
<p>we include <strong>Plain.Full which will give me all available UI elements of Plain</strong> &#8211; currently Tabs and Windows. In the end we just need to start UI.render &#8230;</p>
<p>So now comes the nice stuff, if I want to just change the style of the Tabs and the Windows I <strong>don&#8217;t need to change any of the Functionality Classes</strong>. I just need to change the UI with:</p>
<pre class="brush: jscript; title: ;">
$require(MPR.path + 'Ui/Mocha/Mocha.Full.js');
[...]
UI.render('Mocha');
</pre>
<p>and we get <a href="http://www.delusionworld.com/files/general-mootools-ui/mootools-ui-windows-mocha.html">Mocha Layout</a> for Tabs and Windows.</p>
<p>The<strong> Mocha.Windows is a little bit more complicated</strong> as it needed a Canvas which gets updated on every size change. But in the end it&#8217;s really flexible and the best thing is if you want to change the functionality you don&#8217;t have to think (to much) about they layout. Moreover this also works the other way around. It&#8217;s far easiere to create just the layout for a specific structure than to create all the functionality&#8230;</p>
<p>one other thing that might come in handy is that you can start the UI without any functionality classes&#8230;.<a href="http://www.delusionworld.com/files/general-mootools-ui/mootools-ui-only-mocha.html">Mocha UI only</a>. The html markup has to be created accordingly by a server scripting language or so&#8230; Starting the UI is again pretty simple</p>
<pre class="brush: jscript; title: ;">
$require(MPR.path + 'Ui/Mocha/Mocha.Full.js');
window.addEvent('domready', function() {

	//say we want to use the WindowsUI and the TabsUI
	UI.render('Mocha', {
		'Windows': {
			'param': '.ui-window'
		},
		'Tabs': {
			'param': '.ui-tab'
		}
	});

});
</pre>
<p>I currently can only think of one rule you need to follow (maybe I get some more ofer time&#8230;):</p>
<ul>
<li>include the UI classes always after the functionality classes</li>
</ul>
<p>Limitation:</p>
<ul>
<li>the setOptions method (if the UI is called at the end) only support options while with refactor you can override and define new functions.
</ul>
<h2>Note at the end:</h2>
<p>The setOptions doesn&#8217;t seem to work for subclasses if&#8230; yeah right if I knew that I would fix it, but for now the UI should be called at the top if you need some complex update functions like for MochaUI Window (for all the other stuff it also works at the end) [I guess the problem lies somewhere in between <a href="http://www.delusionworld.com/files/MPR/Ui/Ui.js">the UI - fireEvent('onUiInit');</a> and <a href="http://www.delusionworld.com/files/MPR/Ui/Mocha/Mocha.Windows.js">the UI.Mocha - this.options.refactor.options.onUiInit</a>. If you catch any error - I'm open for suggestions...]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.delusionworld.com/mootools/general-mootools-ui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>progressive vs non-progressive development</title>
		<link>http://www.delusionworld.com/webdev/progressive-vs-non-progressive-development/</link>
		<comments>http://www.delusionworld.com/webdev/progressive-vs-non-progressive-development/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 00:25:03 +0000</pubDate>
		<dc:creator>daKmoR</dc:creator>
				<category><![CDATA[WebDev]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[progressive Enhancement]]></category>
		<category><![CDATA[Tabs]]></category>

		<guid isPermaLink="false">http://www.delusionworld.com/?p=54</guid>
		<description><![CDATA[Progressive Enhancement will not only help you to support different levels of context &#8211; it can also help you during development. So let&#8217;s look at an example again (here is an overview). What we see here is just a simple way of displaying content that might be transformed to tabs. &#60;div class=&#34;FlowTabs&#34;&#62; &#60;h4 class=&#34;Tab&#34;&#62;Short Text&#60;/h4&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Progressive Enhancement will not only help you to support different levels of context &#8211; it can also help you during development. So let&#8217;s look at an <a href="http://www.delusionworld.com/files/progressive-vs-non-progressive-development/progressive.Basic.html">example</a> again (here is an <a href="http://www.delusionworld.com/files/progressive-vs-non-progressive-development/">overview</a>).</p>
<p>What we see here is just a <strong>simple way</strong> of displaying content <strong>that might be transformed to tabs.</strong></p>
<pre class="brush: xml; title: ;">
&lt;div class=&quot;FlowTabs&quot;&gt;
	&lt;h4 class=&quot;Tab&quot;&gt;Short Text&lt;/h4&gt;
	&lt;div class=&quot;TabContent&quot;&gt;Lorem ipsum dolor [...]&lt;/div&gt;
	&lt;h4 class=&quot;Tab&quot;&gt;Long Text&lt;/h4&gt;
	&lt;div class=&quot;TabContent&quot;&gt;Sed ut perspiciatis [...]&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>The h4 could be the title and the div could be the content. So without any js magic it&#8217;s just a header and some content below. It&#8217;s clear that the h4 is the header for the following text. It&#8217;s just simple.</p>
<h2>MooTools Tabs</h2>
<p>Now let&#8217;s look at the <a href="http://www.delusionworld.com/files/progressive-vs-non-progressive-development/progressive.MooTools.html">MooTools version</a>. The <strong>HTML just remains the same</strong>. Some modifications to the css so it&#8217;s look a little bit more like tabs. <em>[this is just an example, no style contest.. :p]</em><br />
The actual javascript is really boring:</p>
<pre class="brush: jscript; title: ;">
window.addEvent('domready', function() {
	$require(MPR.path + 'Tabs/FlowTabs/FlowTabs.inline.js');
	var myTabs = new FlowTabs.inline( $$('.FlowTabs .Tab'), $$('.FlowTabs .TabContent')  );
});
</pre>
<p>Just include the class and say we should <strong>get the tabs from &#8220;.Tab&#8221;</strong> and the <strong>content from &#8220;.TabContent&#8221;</strong>. If we wanted you could <strong>easily change this</strong>. Say we want to use the first h6 as title and the first div as content (without the classes) we only need to change the class call to &#8220;new FlowTabs.inline( $$(&#8216;.FlowTabs h6&#8242;), $$(&#8216;.FlowTabs > div&#8217;)  );&#8221;. So we are <strong>pretty flexible</strong> and can use this in different situation with the same progressive Enhancement functionality. <em>[ok, class creation takes some time - but once you have it it's so nice <img src='http://www.delusionworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  - I wrote this class just as an example for this, but I might release it at some point...]</em></p>
<h2>jQuery Tabs</h2>
<p>This was pretty easy right? Let&#8217;s assume we we want to <strong>change the javascript Framework</strong> (for whatever reason). Now this is usually a pretty bad day for us developers &#8211; means a lot of work and recreate all that stuff (if we wanna do it right and don&#8217;t use 2 Frameworks at the same time). However with <em>progressive Enhancement</em> <strong>half the work is already done</strong>. The style, the content, multi-language support&#8230; &#8211; all that is already working. We <strong>just</strong> need to <strong>recreate the behavior</strong>. I had no &#8220;real&#8221; glue about jQuery but I had it done within less than half an hour. Just take a look at the <a href="http://www.delusionworld.com/files/progressive-vs-non-progressive-development/progressive.jQuery.html">progressive Enhancement version with jQuery</a>. </p>
<pre class="brush: jscript; title: ;">
$('.FlowTabs').prepend('&lt;div class=&quot;inlineTabTabs clearfix&quot;&gt;&lt;/div&gt;');
var tabContainers = $('.FlowTabs .TabContent');
$('.FlowTabs .Tab').each( function(index) {
	$('.inlineTabTabs').append(this);
	$(this).click( function() {
		tabContainers.hide();
		tabContainers.filter(':eq(' + index + ')').show();

		$('.FlowTabs .Tab').removeClass('act');
		$(this).addClass('act');

		return false;
	})
}).filter(':eq(0)').click();
</pre>
<p>The code may not be the nicest and there a certainly some ways to make it more flexible like we can do this with MooTool classes, but I <strong>got it to work within a short time</strong> and it looks and feels exactly the same. I would say <strong>progressive Enhancement at it best</strong> <img src='http://www.delusionworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Now you may wonder why I didn&#8217;t used the <a href="http://stilbuero.de/jquery/tabs_3/">jQuery UI Tabs</a>. It&#8217;s for a simple reason &#8211; it&#8217;s no real progressive Enhancement (in the way I think of it). First the tabs are in a separate ul, li list at the top of all the content. So if you have no javascript all the tab titles will be disconnected from their content. Furthermore the the &#8220;headers&#8221; (tabs-title) are links and connected with their content through anchors. So this link href=&#8221;#myTabContent&#8221; will open the tab with the id=&#8221;myTabContent&#8221;. There are 2 reasons why I don&#8217;t like this: First I don&#8217;t want to create all this id&#8217;s and second why use links? there is no page to go to&#8230; ok, it makes partly sense because the &#8220;headers&#8221; are disconnected with there content, but that&#8217;s just an excuse for the first mistake so we certainly can do better right?</p>
<h2>ExtJS Tabs</h2>
<p>Now I tried to create the same effect with ExtJS, I was quite motivated as MooTools and jQuery went so smoothly. However <strong>the closest to progressive Enhancement I could come up </strong>with is more or less progressive Enhancement. <a href="http://www.delusionworld.com/files/progressive-vs-non-progressive-development/progressive.ExtJS.html">Let&#8217;s take a closer look</a>.</p>
<pre class="brush: jscript; title: ;">
Ext.onReady(function(){
	var tabs = new Ext.TabPanel({
		applyTo: 'FlowTabs',
		activeTab: 0,
		deferredRender: false,
		autoTabs: true
	});
});
</pre>
<p>Now with this &#8220;autoTabs: true&#8221; the TabPanel actually looks for &#8216;&lt;div class=&quot;x-tab&quot; title=&quot;myTabTitle&quot;&gt;&#8217; and create Tabs from it. It&#8217;s easy and again I don&#8217;t need to write many javascript. However I <strong>had to change my HTML so it&#8217;s not progressive Enhancement</strong>. Furthermore the title for the tab is not well displayed without javascript. Also I included the the 532KB ext-all.js and a 81KB ext-all.css, both minified. This quite some stuff and it doesn&#8217;t even let me choose which tabs and content is taken. Wow and yeah it looks different. I didn&#8217;t tried to style it accordingly as I had to change my original 4 lines (from the top &#8211; [basic]) to those 2 lines:</p>
<pre class="brush: jscript; title: ;">
&lt;div class=&quot;x-tab&quot; title=&quot;Short Text&quot;&gt;Lorem ipsum dolor [...]&lt;/div&gt;
&lt;div class=&quot;x-tab&quot; title=&quot;Long Text&quot;&gt;Sed ut perspiciatis [...]&lt;/div&gt;
</pre>
<p>and after the Ext.TabPanel has <strong>transformed it to 49(!!) HTML lines</strong>. You can either look at the code in firebug or look at this page where you can see the <a href="http://www.delusionworld.com/files/progressive-vs-non-progressive-development/ExtJS.generatedCode.txt">output code</a>. ok, this was a little bit to much for me, so I guess <strong>maybe I would need to create my own Ext widget</strong> to make it work, but if I need to write my own code I (me personally) wouldn&#8217;t choose ExtJS. <em>[I might be completely wrong here, as I don't know Ext well enough. However it seems like it works quite different than MooTools or jQuery]</em><strong><br />
Update: you can of course create your own script &#8211; Thomas Fritz was nice enough to provide an <a href="http://fritzthomas.com/files/extjs-progressive-enhancement-example/">example</a>. So it really just depends on your personal preference what Framework you wanna choose.</strong></p>
<h2>non-progressive ExtJS</h2>
<p>Now let&#8217;s take the other way around. We just start with a <a href="http://www.delusionworld.com/files/progressive-vs-non-progressive-development/non-progressive.ExtJS.html">Javascript Version by ExtJS</a>.</p>
<pre class="brush: jscript; title: ;">
Ext.onReady(function(){
	var tabs = new Ext.TabPanel({
		renderTo: 'FlowTabs',
		activeTab: 0,
		plain:true,
		defaults:{autoHeight: true},
		items:[
			{title:'Short Text', html: 'Lorem ipsum dolor [...]'},
			{title:'Long Text', html: 'Sed ut perspiciatis [...]'}
		]
	});
});
</pre>
<p>All the <strong>content is in the javascript</strong> so we don&#8217;t have any html-content that&#8217;s sent by the server. All the transformation from the content (JSON to HTML) is done by javascript. If you don&#8217;t have javascript you see a white page. It&#8217;s so not progressive Enhancement :p. Whenever I want to change content I need to change the javascript (but hey, I don&#8217;t need to change the html&#8230; :p). I don&#8217;t like this way but whatever. </p>
<h2>non-progressive MooTools</h2>
<p>Here we go, so now we have this start from a non-progressive page. I want to port it to another Javascript Framework. So now where do I start. hmmm yeah right &#8211; at the beginning? I don&#8217;t have any html I could take as a base. So I need to recreate everything from scratch again. So let&#8217;s just do it:</p>
<pre class="brush: jscript; title: ;">
var items = [
	{title:'Short Text', html: 'Lorem ipsum dolor [...]'},
	{title:'Long Text', html: 'Sed ut perspiciatis [...]'}
];

var container = new Element('div', { 'class' : 'FlowTabs' });
$each( items, function(el) {
	container.grab( new Element('h4', { 'class': 'Tab', html: el.title }) );
	container.grab( new Element('div', { 'class': 'TabContent', html: el.html }) );
});

$require(MPR.path + 'Tabs/FlowTabs/FlowTabs.inline.js');
var myTabs = new FlowTabs.inline( container.getElements('.Tab'), container.getElements('.TabContent') );

container.inject( $('FlowTabs') );
</pre>
<p>ok, I cheated a little. I just <strong>create the basic html</strong> from above &#8211; <strong>this time simply with javascript</strong>. Strange right? So now I have all this virtual dom element and here comes again a little MooTools magic (sorry for being biased :p). Even though nothing is in the dom, we can still create the object and hand the class the &#8220;virtual&#8221; items. Afterward we inject only the already modified html.</p>
<p>I didn&#8217;t tried to create it again with jQuery as I think it&#8217;s just not worth my time. It&#8217;s worthless time as progressive Enhancement is just way better. <img src='http://www.delusionworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Conclusion</h2>
<p>I&#8217;m <strong>more than ever confident </strong>that <strong>progressive Enhancement</strong> is the way <strong>to use javascript</strong>. And I just need to quote <a href="http://adactio.com/articles/1349/">Jeremy Keith</a> with: &#8220;Think about Ajax from the start but don’t implement it until the very end.&#8221; I can really recommend the first part of <a href="http://adactio.com/articles/1349/">this speak</a> (about the first 20 minutes).<br />
I also believe that there are currently only a few javascript &#8220;plugins&#8221; around that make use of &#8220;real&#8221; progressive Enhancement and that&#8217;s really sad as it saves time and give your content some sort of universality. Even if all the design all the behavior changes, your true content will always stay the same.</p>
<p>If there where a package based javascript library that would follow true progressive Enhancement with the same amount of features as the current ExtJS framework than I might not need to write this article <em>(if anyone knows something just let me know)</em>. I doubt it so I will just try to create such a library (just step by step) and I think the perfect base for something like this is MooTools.</p>
<p><em>Update: so here we are again &#8211; thx to an <a href="http://fritzthomas.com/files/extjs-progressive-enhancement-example/">example</a> from Peter Fritz every Framework just masters all the requirements. So yet again it&#8217;s just your personal preference what Framework you choose.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.delusionworld.com/webdev/progressive-vs-non-progressive-development/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>progressive Enhancement</title>
		<link>http://www.delusionworld.com/webdev/progressive-enhancement/</link>
		<comments>http://www.delusionworld.com/webdev/progressive-enhancement/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 16:56:42 +0000</pubDate>
		<dc:creator>daKmoR</dc:creator>
				<category><![CDATA[WebDev]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[progressive Enhancement]]></category>

		<guid isPermaLink="false">http://www.delusionworld.com/?p=24</guid>
		<description><![CDATA[What is progressive Enhancement? (from wikipedia) Progressive enhancement is a strategy for web design that emphasizes accessibility, semantic markup, and external stylesheet and scripting technologies. Progressive enhancement uses web technologies in a layered fashion that allows everyone to access the basic content and functionality of a web page, using any browser or Internet connection, while [...]]]></description>
			<content:encoded><![CDATA[<p>What is progressive Enhancement? (from wikipedia)</p>
<blockquote><p><strong>Progressive enhancement</strong> is a strategy for <a title="Web design" href="http://en.wikipedia.org/wiki/Web_design">web design</a> that emphasizes accessibility, semantic markup, and external stylesheet and scripting technologies. Progressive enhancement uses web technologies in a layered fashion that allows everyone to access the basic content and functionality of a web page, using any browser or Internet connection, while also providing those with better bandwidth or more advanced browser software an enhanced version of the page.</p></blockquote>
<p>So in other words you start with the most basic concept and evolve it with every step (but the <strong>basic concept always stays the same</strong>). So let&#8217;s do an <a href="http://www.delusionworld.com/files/progressive-enhancement/">example</a> (there you can see the actual code) [please don't use IE :p]:</p>
<h2>Basic</h2>
<p>Here we have the basic setup &#8211; simple html so even without css and everything the user will still be able to know what&#8217;s going on.<br />
As you can see it&#8217;s just about providing a Headline + some Help for a bunch of Input fields.</p>
<pre class="brush: xml; title: ;">
&lt;h4&gt;Server Configuration&lt;/h4&gt;
&lt;a href=&quot;help.php?id=Server&quot;&gt;&lt;span&gt;(Help)&lt;/span&gt;&lt;/a&gt;
&lt;div&gt; Here are a lot of Inputs &lt;/div&gt;
&lt;h4&gt;General Configuration&lt;/h4&gt;
&lt;a href=&quot;help.php?id=General&quot;&gt;&lt;span&gt;(Help)&lt;/span&gt;&lt;/a&gt;
&lt;div&gt; Here are a lot of Inputs &lt;/div&gt;
</pre>
<h2>CSS Enhanced</h2>
<p>So now the HTML is completely the same we just add some CSS. With this it just looks nicer, but if at any time we remove the CSS it still makes sense. However I&#8217;m sure most of you know how to handle CSS.</p>
<pre class="brush: css; title: ;">
.cssEnhanced h4 { display: inline-block; margin: 10px 0 5px; }
.cssEnhanced a { background: url('img/help.png'); width: 16px; height: 16px; display: inline-block; margin-left: 5px; }
.cssEnhanced a span { display: none; }
</pre>
<h2>JS Enhanced</h2>
<p>With a little javascript we can do even more.</p>
<pre class="brush: jscript; title: ;">
$require('jsEnhanced.css'); //load a css with js, so it will only be included if js is enabled

window.addEvent('domready', function() {
	$require(MPR.path + 'Tools/Roar/Roar.js');
	var roar = new Roar();

	$$('.jsEnhanced a').each( function(el) {
		// load all message on startup - could also be done on mouseenter or click (would require a cache check)
		new Request.JSON({
			'url' : el.get('href') + '&amp;ajax=1',
			'method' : 'get',
			onComplete : function(tree, elements, html) {
				el.store('content', tree);
			}
		}).send();

		el.addEvents({
			'mouseenter': function() {
				roar.alert(el.retrieve('content').header, el.retrieve('content').msg );
			},
			'click': function(e) {
				e.stop(); // or return false; as we don't want to go to the page as the info is provided with js
			}
		});
	});  // $$('.jsEnhanced a').each(

});
</pre>
<p>First at line 1 we load an additional css with javascript to modify the image to show it doesn&#8217;t require a click. If javascript is disabled the icon will just stay as it was.</p>
<p>Then we wait for the dom to be ready(3), as afterward we just loop through all jsEnhanced links(7) and request all the messages we will need for this page(9-15). For the Request Url we just <strong>us the href from the link</strong> and add an <em>ajax=1</em>. By doing this the <a href="http://www.delusionworld.com/files/progressive-enhancement/help.txt">script</a> that provides the messages will know that we don&#8217;t need all the usual html stuff &#8211; just the data encoded in json.<br />
After the Request is Complete(12) we just <strong>save the output to the link</strong>(13). Finally we just add 2 Events to the links. One to display the message on hover(18) and one to stop the default click as we don&#8217;t want to see the standalone info page. [Note: we could also reshow the message on click or do something else]</p>
<h2>Javascript multi-language support for free</h2>
<p>So if you stick to the progressive enhancement you don&#8217;t even need to create a multi-language support for javascript on your own. Just create <strong>proper html</strong> code with your <strong>favorite server side programming language</strong>. And with proper I mean make the whole page with html first and <strong>enhance it afterward</strong>. So what do I mean by &#8220;get it for free&#8221;. Until now the html code has always been the same, just enhanced with css and javascript. So if I just create a <strong>multi-language support for html</strong> (and you will always need that) I don&#8217;t even need to touch my css or javascript as it will then just enhance my different language. So let&#8217;s change the html a little:</p>
<pre class="brush: xml; title: ;">
&lt;h4&gt;Konfiguration des Servers&lt;/h4&gt;
&lt;a href=&quot;help.php?id=Server&amp;lang=de&quot;&gt;&lt;span&gt;(Hilfe)&lt;/span&gt;&lt;/a&gt;
&lt;div&gt;Hier gibt es eine Menge Inputs&lt;/div&gt;
&lt;h4&gt;Allgemein Konfiguration&lt;/h4&gt;
&lt;a href=&quot;help.php?id=General&amp;lang=de&quot;&gt;&lt;span&gt;(Hilfe)&lt;/span&gt;&lt;/a&gt;
&lt;div&gt;Hier gibt es eine Menge Inputs&lt;/div&gt;
</pre>
<p>Now it&#8217;s some German HTML with links to German help files (or in this case just a config for the script). <strong>I didn&#8217;t changed any css or js and it still works</strong>. So the only reason you need multi-language support in javascript is when you are lazy and don&#8217;t want to create proper html/css. I mean even if you have some messages that only make sense if you have javascript &#8211; just include them hidden?.</p>
<p>There are only TWO thing I can think of where you might want to have multi-language support in javascript. <em>ONE</em> is validation of inputs on the client and you don&#8217;t want to submit the form every time a user changes something so you can provide error messages. However it&#8217;s not even a real good exception, as</p>
<ol>
<li>with ajax request you could submit a form without disturbing the user</li>
<li>you still need a server side validation</li>
<li>you could include the messages as hidden content</li>
</ol>
<p><em>TWO</em> would be <strong>real javascript applications</strong> like a RichTextEditors or drawing canvas/svg &#8211; things that won&#8217;t display in any way as html.</p>
<p>So I would forgive you if you use multi-language support for javascript in these special cases.</p>
<p><em>What you can expect next &#8211; development comparison progressive enhancement vs non-progressive.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.delusionworld.com/webdev/progressive-enhancement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

