<?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>geedew :: Web Design, Programming, Professionalism &#187; HTML</title>
	<atom:link href="http://www.geedew.com/category/programming/html-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geedew.com</link>
	<description>Web Design, Web Programming, Programming on Linux, CSS, JavaScript, PHP, HTML5</description>
	<lastBuildDate>Thu, 22 Jul 2010 16:26:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>jQuery UI Dialog Accessibility</title>
		<link>http://www.geedew.com/2010/02/25/jquery-ui-dialog-accessibility/</link>
		<comments>http://www.geedew.com/2010/02/25/jquery-ui-dialog-accessibility/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 02:52:17 +0000</pubDate>
		<dc:creator>Drew</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[508]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[BugFix]]></category>
		<category><![CDATA[Defects]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://www.geedew.com/?p=185</guid>
		<description><![CDATA[jQuery UI is an amazing product. It&#8217;s not because it offers the best features, or that it offers the best solution, it&#8217;s that it offers a large degree of support for years to come. Which is saying a lot for something that is nothing more than JavaScript. It&#8217;s certainly something that many enterprises have begun [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=b02858dd9961de60a8a7d0f9efe9c758&amp;default=http://use.perl.org/images/pix.gif' alt='No Gravatar' width=20 height=20/><p>    jQuery UI is an amazing product.  It&#8217;s not because it offers the best features, or that it offers the best solution, it&#8217;s that it offers a large degree of support for years to come.  Which is saying a lot for something that is nothing more than JavaScript.  It&#8217;s certainly something that many enterprises have begun to look at and look for in the development world.  At my job at Coventry Healthcare, I&#8217;m responsible for the User Interfaces and generally the User Experience across some very highly visible web applications.  One of the most recent developments in our line of business is the risk of not having an accessible site (we fall under Section 508 guidelines because of our Medicare/Medicaid users).  jQuery UI has literally allowed me to very easily create and maintain large amounts of code so that I can spend more time making sure that it follows WCAG 2.0 and WARIA (which should cover us for S508).<span id="more-185"></span>
</p>
<p class="entry-text">So recently I discovered a very nasty bug dealing with jQuery UI dialog (withe modal:true) widgets that seems to only occur in Internet Explorer.  It goes like this:  If you are using a dialog with a screen reader, your main mode of navigation is with the keyboard.  This is typically driven via the focus on elements.  In jQuery, focus is demanded on the dialog because of the modal command.  You are unable to focus on anything other than the dialog and it&#8217;s elements.  Here&#8217;s the issue however, jQuery successfully  can keep focus on the dialog in all browsers tested (FF, Safari, Chrome) so that the focus cannot leave the dialog.  However in Internet Explorer (6, 7 and 8 ) your focus can get to the address bar, simply by tabbing to it.  Once in the address bar, jQuery is no longer able to track and handle the focus, so inevitable, after tabbing through the menu, focus come back to the window.  But instead of going to the dialog, it goes to the first element that can be tabbed to, which is undoubtedly BEHIND the modal dialog.  jQuery, subsequently locks the tabbing at this point, most likely because you have focus on and element that is unable to be focused (in jQuery&#8217;s dialog algorithm).
</p>
<p class="entry-text">So I cannot have this as that would literally cut 75% of my users from being able to use just a keyboard with the sites I&#8217;m maintaining.  So I had to find a solution.  First, IE seems to be the only browser with this issue and it has something to do with the fact that the focus moves out of the DOM&#8217;s control (out of jQuery&#8217;s control).  But the focus would always at least get back to the first element that could be tabbed to, and then lock.  So I devised a plan.  What if the first element, when focused, looks for an open dialog and if it is there, focuses on that dialog?  So I tried it out, like this.
</p>
<pre class="brush: jscript;">
$(document).ready(function() {
    $(&quot;:tabbable:first&quot;).focus(function() {
           $(&quot;.ui-dialog:visible:last :tabbable:first&quot;).focus();
    })
});
</pre>
<p class="entry-text">
Amazingly enough, this is the exact solution to the issue. This is how it reads.</p>
<ol>
<li>On page load</li>
<li>Get the first element that can be tabbed to in the body</li>
<li>When this element gains focus, check for a visible dialog</li>
<li>Take the visible dialog that is last (the last one drawn in the html) and get the first element that can be tabbed in it</li>
<li>give focus to that first element.</li>
</ol>
<p class="entry-text">
Now, in IE, when focus returns to the document, it goes to the dialog box, specifically, the close icon on the dialog box, thereby not breaking the fact that there a modal open on the page.
</p>
<p class="entry-text">
Now, there are some issues with this.  For one, the code is just assuming that the last dialog in the html that is visible is the one that is to be focused on.  Quite frankly, that&#8217;s what I need it for, as I try not to overlay dialogs, and when it do, the newest one is normally always on top.  However, there are times where you may swap between two dialogs, and the one that is on top is not the last dialog in the html, you would still have this issue in this case.  But for probably the other 95% of the cases, this is a clean and easy way to &#8216;fix&#8217; the accessibility issue in IE with jQuery UI dialog modals.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geedew.com/2010/02/25/jquery-ui-dialog-accessibility/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Usability and a Simple JavaScript hovering menu</title>
		<link>http://www.geedew.com/2009/12/05/usability-and-a-simple-javascript-hovering-menu/</link>
		<comments>http://www.geedew.com/2009/12/05/usability-and-a-simple-javascript-hovering-menu/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 02:20:11 +0000</pubDate>
		<dc:creator>Drew</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://geedew.com/blog/?p=53</guid>
		<description><![CDATA[Many web developers ask &#8216;what is usability?&#8217;.  This is one of those topics that I can explain, but it may be easier to demonstrate. My this experiences have led to some principles; one of them is that if I&#8217;m going to build it, it must be usable.   Unfortunately, many sites that I like, that tout [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=b02858dd9961de60a8a7d0f9efe9c758&amp;default=http://use.perl.org/images/pix.gif' alt='No Gravatar' width=20 height=20/><p>Many web developers ask &#8216;what is usability?&#8217;.  This is one of those topics that I can explain, but it may be easier to demonstrate. My this experiences have led to some principles; one of them is that if I&#8217;m going to build it, it must be usable.   Unfortunately, many sites that I like, that tout usability, screw up one important concept that annoys me greatly.</p>
<p>I ask myself, &#8220;when using a menu, why do I have to drag my mouse from one button to the next, and fear losing the menu if I cross it&#8217;s border anywhere?&#8221;  Some menus are just annoying because they disappear mid mouse move, some are extremely hard to use because of several layers of menus, some I have resorted to using `tabs` to get to the correct menu item.  It&#8217;s unfortunate that people can&#8217;t get this right.<br />
<span id="more-53"></span><br />
I have a simple fix that hopefully sharing it will help others.  It&#8217;s basically a menu that buffers the time you are hovering, that way if you mistakenly move your mouse into the wrong area, you have a brief period of time to correct yourself.</p>
<h2>Start with the HTML code:</h2>
<pre class="brush: xml;">
&lt;ul id=&quot;menu&quot;&gt;
	&lt;li class=&quot;nav&quot;&gt;&lt;a&gt;&lt;span&gt;ONE&lt;/span&gt;&lt;/a&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;one&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;two&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;three&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;four&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;a&gt;&lt;span&gt;TWO&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li class=&quot;nav&quot;&gt;&lt;a&gt;&lt;span&gt;THREE&lt;/span&gt;&lt;/a&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;one&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;two&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;three&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;four&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li class=&quot;nav&quot;&gt;&lt;a&gt;&lt;span&gt;FOUR&lt;/span&gt;&lt;/a&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;one&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;two&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;three&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a&gt;&lt;span&gt;four&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>The menu is a simple list within a list.  There are essentially only four main list items; ONE, TWO, THREE and FOUR.  Each of this list items has their own list of list items generically named one, two, three and four.  I personally stick with lists as my menu&#8217;s of choice because they degrade gracefully in case of CSS/JavaScript issues.</p>
<p>This list by itself isn&#8217;t much, in fact it&#8217;s not even a menu. CSS will be needed to really make it work correctly.</p>
<pre class="brush: css;">

#menu li {
	list-style:none;
	float:right; /* Makes IE 6,7,8 act like FF */
	position: relative;}
#menu li a {
	display:block;
	width: 160px;
	height:35px;
	margin-top: 5px;}
#menu li a span{
	padding-left:10px;
	line-height:2.8em;
	color: #000000;
	font-weight:700;}
#menu li a:hover {
	font-weight:bold;}

#menu li ul li a:hover span{ color: #222222; }

	#menu li ul {
		margin:0px;
		position:absolute;
		left: 160px;
		top:-90px;}
	#menu li ul li {
		padding:0px;
		border:0px;
		border-collapse:collapse;
		margin:0px;
		height:34px;}
	#menu li ul li a{ margin:0px;padding:0px;border:0px;}
	#menu li ul li a span{
		display:block;
		padding-top:7px;
		font-weight:100;
		line-height:1em;
		font-size: 83%;}
</pre>
<p>This is some simple CSS that will make the UL/LI lists to really act like lists.  Now the only issue is that you need it to act like a list. So the final piece of code to this puzzle is to add some JavaScript.  I am using the jQuery library as my choice for creating this script, so it&#8217;s necessary to have that package (1.3+) installed for this to work. You can drop this script into the footer element inside of &#8216;script&#8217; tags so it will run.  It will run automatically on page load.</p>
<pre class="brush: jscript;">
$(document).ready(function() {
	/* Setup the Menu */
	$(&quot;#menu &gt; li &gt; ul&quot;).hide();

	$(&quot;#menu li.nav&quot;).hover(
		/* on mouseover */
		function(e) {
			hoverMenu = this;
			if(this == closingMenu) {
				clearTimeout(closeMenu);
				clearTimeout(openMenu);
				$(this).find(&quot;ul:first&quot;).show(&quot;fast&quot;);
			} else {
				var newMenuOpen = function() {
					$(hoverMenu).siblings(&quot;.nav&quot;).find(&quot;ul:first&quot;).hide();
					$(hoverMenu).find(&quot;ul:first&quot;).show(&quot;fast&quot;);
				}
				openMenu = setTimeout(newMenuOpen, 500);
			}

		},
		/* on mouseout */
		function(e) {
			closingMenu = this;
			var closeMenu = function() {
				$(closingMenu).find(&quot;ul:first&quot;).fadeOut(&quot;fast&quot;);
			}
			closeMenu = setTimeout(closeMenu, 500);
		}
	);
});
</pre>
<p> The final product is quite a nice and simple dynamic menu that adds just the right touch of usability.  Now, typically, I would never say that a menu with sub menus popping up everywhere is something of a usability menu system, it&#8217;s not.  But sometimes, a nice menu like this is needed, especially if there is a lot of information and &#8216;drill downs&#8217; that need to be accessed quickly.  In any case, you can see my <a href="http://www.geedew.com/projects/easyMenu/index.html">demo</a> here.  Leave some comments if you have any questions, and enjoy! You can also see a fully implemented version at <a href="http://x-sqared.com">Xcessorries Squared.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.geedew.com/2009/12/05/usability-and-a-simple-javascript-hovering-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scribd and Slide mode : Why is my height wrong?</title>
		<link>http://www.geedew.com/2009/07/29/scribd-and-slide-mode-why-is-my-height-wrong/</link>
		<comments>http://www.geedew.com/2009/07/29/scribd-and-slide-mode-why-is-my-height-wrong/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 05:06:02 +0000</pubDate>
		<dc:creator>Drew</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Scribd]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[BugFix]]></category>

		<guid isPermaLink="false">http://www.geedew.com/?p=106</guid>
		<description><![CDATA[While recently using Scribd&#8216;s services, I came across a very nasty bug, and a nice clean fix.  Scribd allows developers to tap into a great, but somewhat basic API.  One of these settings allows a developer to set a default &#8216;mode&#8217; before the API then builds the flash calls necessary to display the document.  The [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=b02858dd9961de60a8a7d0f9efe9c758&amp;default=http://use.perl.org/images/pix.gif' alt='No Gravatar' width=20 height=20/><p>While recently using <a href="http://www.scribd.com/about">Scribd</a>&#8216;s services, I came across a very nasty bug, and a nice clean fix.  <a href="http://www.scribd.com/about">Scribd</a> allows developers to tap into a great, but somewhat basic <a href="http://www.scribd.com/developers/api?method_name=Javascript+API">API</a>.  One of these settings allows a developer to set a default &#8216;mode&#8217; before the <a href="http://www.scribd.com/developers/api?method_name=Javascript+API">API</a> then builds the flash calls necessary to display the document.  The issue comes up when you choose the &#8216;slide&#8217; mode as the loading view.  No matter what &#8216;height&#8217; you set, with &#8216;auto_size&#8217; set to false, the height will adjust to the wrong height.</p>
<p><span id="more-106"></span></p>
<p class="entry-text">
You can jump to the code <a href="#finishedCode">here</a>, or continue.</p>
<p class="entry-text">
I started by writing some simple code that follows the API.
</p>
<pre class="brush: jscript;">
scribd_doc.addParam( 'mode', 'slide' );
scribd_doc.addParam( 'height', 800 );
scribd_doc.addParam( 'width', 600 );
scribd_doc.addParam( 'jsapi_version', 1 );
scribd_doc.addParam( 'auto_size', false );
scribd_doc.write( 'flash_catalog' );
</pre>
<p class="entry-text">Where &#8216;flash_catalog&#8217; is the container div of the <a href="http://www.scribd.com/about">Scribd</a> PDF.</p>
<p class="entry-text">
This however led me to have a height that follows the default rules (width multiplier of 85/110) where the height matches how much space is in the window. So I progressed further with this code.</p>
<pre class="brush: jscript;">
var oniPaperReady = function(e){
 $(&quot;#flash_catalog embed&quot;)
.attr(&quot;wmode&quot;,&quot;transparent&quot;)
.hide()
.css({&quot;height&quot;:&quot;800px&quot;, &quot;width&quot;:&quot;600px&quot;})
.show();
}

scribd_doc.addEventListener( 'iPaperReady', oniPaperReady );
scribd_doc.addParam( 'mode', 'slide' );
scribd_doc.addParam( 'jsapi_version', 1 );
scribd_doc.addParam( 'auto_size', false );
scribd_doc.write( 'flash_catalog' );
</pre>
<p class="entry-text">So now I am dropping in a listener in the API to wait for the document to load.  I then hide the &#8216;embed&#8217; flash information, then add the height and width, then re-show the flash element.<?p></p>
<p class="entry-text">
You may notice, I&#8217;m using <a href="http://jquery.com/">jQuery</a>, in which you can do the same thing with regular JavaScript, although quite a bit more complicated (ask if you really really need that code).</p>
<p class="entry-text">
An astute reader would also notice one thing, I&#8217;m not adjusting for an &#8216;object&#8217; tag, only the &#8216;embed&#8217; tag (the difference for flash between different browsers).  I figured out this novice mistake while testing in Internet Explorer.  Here&#8217;s the finished code, that works, removing the nasty height issue.</p>
<div id="finishedCode">
<pre class="brush: jscript;">
var scribd_doc = scribd.Document.getDoc( #######, 'key-*******************' );

var oniPaperReady = function(e){
$(&quot;#flash_catalog embed&quot;)
.attr(&quot;wmode&quot;,&quot;transparent&quot;)
.hide()
.css({&quot;height&quot;:&quot;800px&quot;, &quot;width&quot;:&quot;600px&quot;})
.show();

$(&quot;#flash_catalog object&quot;)
.attr(&quot;wmode&quot;,&quot;transparent&quot;)
.hide()
.css({&quot;height&quot;:&quot;800px&quot;, &quot;width&quot;:&quot;600px&quot;})
.show();
}

scribd_doc.addEventListener( 'iPaperReady', oniPaperReady );
scribd_doc.addParam( 'mode', 'slide' );
scribd_doc.addParam( 'jsapi_version', 1 );
scribd_doc.addParam( 'auto_size', false );
scribd_doc.write( 'flash_catalog' );
</pre>
</div>
<p class="entry-text">The final word; I&#8217;m adding the transparent mode so that I can then have a menu that drops on top of the flash.  This works very well!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geedew.com/2009/07/29/scribd-and-slide-mode-why-is-my-height-wrong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
