<?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>Jens Arps &#187; widget</title>
	<atom:link href="http://jensarps.de/tag/widget/feed/" rel="self" type="application/rss+xml" />
	<link>http://jensarps.de</link>
	<description></description>
	<lastBuildDate>Tue, 07 Sep 2010 14:11:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Keyboard accessibility for dojox.layout.FloatingPane</title>
		<link>http://jensarps.de/2009/11/02/keyboard-accessibility-for-dojox-layout-floatingpane/</link>
		<comments>http://jensarps.de/2009/11/02/keyboard-accessibility-for-dojox-layout-floatingpane/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 19:26:58 +0000</pubDate>
		<dc:creator>Jens Arps</dc:creator>
				<category><![CDATA[Dojo Love]]></category>
		<category><![CDATA[Experiments in Web]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[dojox]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://jensarps.de/?p=94</guid>
		<description><![CDATA[Well, I don&#8217;t really see a use for FloatingPane, except as a windowing system for projects like LucidDesktop, but I got the impression that many people just love the FloatingPane. However, it caught my attention these days.
One of its major drawbacks – and the one that keeps it pretty far from becoming a joyful member ]]></description>
			<content:encoded><![CDATA[<p>Well, I don&#8217;t really see a use for FloatingPane, except as a windowing system for projects like <a href="http://www.lucid-desktop.org/" target="_blank">LucidDesktop</a>, but I got the impression that many people just love the FloatingPane. However, it caught my attention these days.</p>
<p>One of its major drawbacks – and the one that keeps it pretty far from becoming a joyful member of the dijit namespace – is the lack of keyboard accessibility. It has plenty of other issues and could use some refactoring, but this one is outstanding. Hm, adding keyboard access shouldn&#8217;t be too hard I thought and went for it…<br />
<span id="more-94"></span><br />
<strong>1. Moving and resizing</strong></p>
<p>To enable keybord movement, there are some prequesites: First, the pane needs to be able to recieve focus and move itself to front via the keyboard. Second, the pane needs a lot of visual markers. And it needs a certain state in which the keybord movement can actually be activated.</p>
<p>So, the idea is the following: If you tab through the panes, the focus is set to the pane&#8217;s title node. If you click into a pane or into its child widgets, you need to shift-tab upwards until the title node recieves focus. In my minimal styling, the title node text is in <em>italics</em> when it has focus. You can then press space to &#8220;activate&#8221; keyboard movement. An overlay is shown to indicate that the &#8220;moveMode&#8221; is active. Then you can use the arrow keys to move, and shift-arrow to resize the pane. To exit this mode, press space or escape or take the focus off the title node by clicking somewhere else or tab away.</p>
<p>In short, the first step included:</p>
<ul>
<li>Adding visual hints to indicate which FloatingPane is on top (via box-shadow and a bold title node text)</li>
<li>Adding a visual hint to indicate when the focus is on the title node and &#8220;moveMode&#8221; can be activated</li>
<li>Enabling the pane to get on top of other panes by tabbing to it</li>
<li>Adding key handlers to start and end &#8220;moveMode&#8221;</li>
<li>Adding typematic key listerners to realize movement</li>
</ul>
<p>Oh, did I mention that dojo&#8217;s typematic is awesome? Nope? Well, it&#8217;s awesome! Go try it out for yourself!</p>
<p><strong>2. Minimize, maximize, restore and the dock</strong></p>
<p>The FloatingPane also has docking abilities – so the dock and it&#8217;s items had be accessible, too. The dock items have their own widget class, so this had to be modified. The changes are minor: adding a tabIndex and a keyhandler. And, of course, adding a visual hint to indicate that the dock item has focus (that is, the label is bold). When the dock item has focus, press space to restore the corresponding pane.</p>
<p>Next, the pane needed extra key handling: I chose &#8220;+&#8221; to maximize, &#8220;-&#8221; to minimize (or restore, if pane is maximized) and &#8220;x&#8221; to close the pane.</p>
<p><strong>3. Baking it all together</strong></p>
<p>As it isn&#8217;t that desireable to have two widgets doing the same in the dojox namespace, I merged the changes with FloatingPane. But, then again, as I did some other minor changes to FloatingPane (but including changes to the CSS classNames to have a consistent use of baseClass, and inheriting from dijit.layout.ContentPane instead of dojox.layout.ContentPane), I named the new widget &#8220;WindowPane&#8221;.</p>
<p><strong>What&#8217;s left?</strong></p>
<p>Short: A ton. The widget needs to be refactored, it has a couple of bugs. The code I added is undocumented, the CSS incomplete. Well, I&#8217;ll be short on time for a week or two, but I&#8217;ll surely get back to this. Consider this a work in progress. But, hey, maybe having keybord accessibility will give further develepmont of this widget a little push.</p>
<p><strong>You want to use it?</strong></p>
<p>Cool, there are two options:</p>
<p>- You can use dojox.layout.Window to gain just movement/resize abilities. Then bake Window.js and the extra CSS from the test page into your build, replace calls to FloatingPane with calls to Window, and you&#8217;re done.<br />
- Or, if you don&#8217;t use FloatingPane yet or want the complete functionality, grab the WindowPane.js file, the WindowPane.css file and the WindowPane.html template and add them to your dojox. This is probably the best way to do.</p>
<p>See below for files.</p>
<p><strong>Keybord summary</strong></p>
<p>Use Tab to navigate from pane to pane, and press space when the title node has focus (title text is itailc) to activate keyboard interaction.</p>
<p>Arrow keys: move pane around<br />
Shift + arrow keys: resize pane<br />
plus: maximize pane<br />
minus: minimize pane or restore pane (if maximized)<br />
x: close pane</p>
<p>Press space again or escape to deactivate keyboard interaction. Or just tab or click away.</p>
<p><strong>Files:</strong></p>
<p>Step one (moving and resizing):</p>
<ul>
<li><a href="http://jensarps.de/tests/dojo_tests/dojo-release-1.4.0-src/dojox/layout/Window.js" target="_blank">/dojox/layout/Window.js</a></li>
<li><a href="http://jensarps.de/tests/dojo_tests/dojo-release-1.4.0-src/dojox/layout/tests/test_Window.html" target="_blank">test page</a></li>
</ul>
<p>Or: Step three (full)</p>
<ul>
<li><a href="http://jensarps.de/tests/dojo_tests/dojo-release-1.4.0-src/dojox/layout/WindowPane.js" target="_blank">/dojox/layout/WindowPane.js</a></li>
<li><a href="http://jensarps.de/tests/dojo_tests/dojo-release-1.4.0-src/dojox/layout/resources/WindowPane.html" target="_blank">/dojox/layout/resources/WindowPane.html</a></li>
<li><a href="http://jensarps.de/tests/dojo_tests/dojo-release-1.4.0-src/dojox/layout/resources/WindowPane.css" target="_blank">/dojox/layout/resources/WindowPane.css</a></li>
<li><a href="http://jensarps.de/tests/dojo_tests/dojo-release-1.4.0-src/dojox/layout/tests/test_WindowPane.html" target="_blank">test page</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jensarps.de/2009/11/02/keyboard-accessibility-for-dojox-layout-floatingpane/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A collapsible fieldset as dojo widget</title>
		<link>http://jensarps.de/2009/10/16/a-collapsible-fieldset-as-dojo-widget/</link>
		<comments>http://jensarps.de/2009/10/16/a-collapsible-fieldset-as-dojo-widget/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 18:43:01 +0000</pubDate>
		<dc:creator>Jens Arps</dc:creator>
				<category><![CDATA[Dojo Love]]></category>
		<category><![CDATA[Goodies to go]]></category>
		<category><![CDATA[dijit]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://jensarps.de/?p=59</guid>
		<description><![CDATA[Though many people would disagree, I for one like to use fieldsets to structure complex forms. Even better do I like fieldsets that are collapsible.
As there is no such fieldset with dojo, I decided to write my own widget. While doing so, I learnt an interesting lesson…
First, I wrote it pretty simple, inheriting the widget ]]></description>
			<content:encoded><![CDATA[<p>Though many people would disagree, I for one like to use fieldsets to structure complex forms. Even better do I like fieldsets that are collapsible.</p>
<p>As there is no such fieldset with dojo, I decided to write my own widget. While doing so, I learnt an interesting lesson…</p>
<p>First, I wrote it pretty simple, inheriting the widget from dijit._Widget and dijit._Templated. It had a toggle button next to its legend, which could be clicked. The toggle was a simple display none/block change.<br />
<span id="more-59"></span><br />
But I wanted it to be accessible via the keyboard – so I added a tabIndex and a key handler. Next, I wanted it to be able to hold and parse widgets, so I inherited it from dijit.layout.ContentPane so I could make use of the content setter. Then I wanted it to animate smoothly, so I added animations, and so on… You get the point, I guess. Well, this went on for a while, until I made an unpleasant discovery: My fieldset was almost a clone of dijit.TitlePane. Ugh.</p>
<p><em>I had put all the time into creating a copy of something, that already existed.</em></p>
<p>So I inherited the fieldset widget from dijit.TitlePane and ended up with less than 50 lines of code. And it was a matter of minutes to do so. Ok, lesson learned: If you need something that doesn&#8217;t exist and you are going to code it – first check if there&#8217;s something that behaves similar to what you want. Or similar to what you <em>might want in the future</em>. If I had invested a little more time in thinking about the fieldset widget before starting to code, it would have been obvious that I wanted the above mentioned features one day. And I would have saved a lot of time.</p>
<p>Well, however, here it is: a collapsible fieldset, coming with all the ContentPane goodness (child widgets, remote loading,…).</p>
<p>You can create it via markup (I put it into a namespace called &#8220;app&#8221;; choose a namespace you like):</p>
<pre>&lt;fieldset dojotype="app.Fieldset"&gt;
    &lt;legend&gt;Legend&lt;/legend&gt;
    Content
&lt;/fieldset&gt;</pre>
<p>or programmatically:</p>
<pre>var fieldset = new app.Fieldset({legend:'dojo fieldset', id: 'someId'},dojo.create('div',{},dojo.body()));</pre>
<p>The fieldset takes pretty much the same arguments as dijit.TitlePane. To change the legend, use <code>dojo.attr('legend','Teh new legend')</code>, to change the content <code>dojo.attr('content',content)</code> as usual. To stay close to TitlePane, I left <code>_setTitleAttr()</code> in it, but it is an alias for <code>_setLegendAttr()</code>.</p>
<p>The code is simple (after I inherited from TitlePane), I only added a method to setup the legend tag and changed the methods that handle hover states, as the TitlePane&#8217;s methods paid no respect to the dijit&#8217;s base class. The fieldset is closed by default, but you can add <code>open="true"</code> to the markup (or add <code>open: true</code> to the constructor args) to make it start open. You can style it as you would style any other widget.</p>
<p>The testpage is over here: <a href="http://jensarps.de/tests/dojo_tests/test_Fieldset.html" target="_blank">test_Fieldset.html<br />
</a> Code: <a href="http://jensarps.de/tests/dojo_tests/dojo-1.3.2/app/Fieldset.js" target="_blank">Fieldset.js</a><br />
Template: <a href="http://jensarps.de/tests/dojo_tests/dojo-1.3.2/app/templates/Fieldset.html" target="_blank">Fieldset.html</a></p>
<p><strong>Update</strong>: If you have downloaded the code and intend to use it, please re-download it, as I updated a method and fixed a namespace confusion (and added doc).</p>
]]></content:encoded>
			<wfw:commentRss>http://jensarps.de/2009/10/16/a-collapsible-fieldset-as-dojo-widget/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
