Axs 1.2

C. Blouch

March 10, 2009

Abstract

Axs is a small Javascript library which provides methods which make it easier for web developers to implement modern Web 2.0 sites with accessible features. These methods are categorized into primary and secondary methods. Included in the library are:
Primary
Secondary

What's In the Package

readme.htmlWhat you are reading right now
axs.jsThe library which makes it all happen
changelog.htmlList all the new fixes and features by version and date
keychart.htmlShows available key combinations in different browsers

Demos

KeycapUses keyreg, keychart, focus, gdoc, id, r and ae methods.
Get Elements By Class NameUses gecn, log, id and ae methods.
Flash XOXOUses flash_xoxo, id and ae methods.
High Contrast DetectUses hc, r, id, and focus methods.
Flash DetectUses fd and log methods.
MSAA DetectUses md and log methods.
The easiest way to understand some of what the axs library does is to try out the demos listed above. In the sections below we describe what the demos are showing.
Keycaps
Here are some interesting use cases. Reload the page between each example.
  1. Type control+alt+G and you will see all four boxes get loaded up with new content via ajax. This leverages the gDoc method to Ajax in the new content, the keyreg method to map control+alt+G to our box loader and the focus method to move the focus to the first box. To see what other keyboard shortcut are set up you can press control+alt+H for help. These type of shortcut are global so you can use it anytime you have focus on the page.
  2. Tab into the page. You should see a visibly hiddne link reveals itself appears saying "Click this link to visibly show or hide the keyboard shortcut table". Hit return and you will see all they keyboard mappings for this page. Hit return again and they go away. This allows keyboard-only users to discover the keybaord shortcuts table without impact to the visual design. As you can see on the chart there are several key combinations registered to update individual boxes. Press control+alt+7 to move focus to box 1 and then hit control+alt+L and you should see box 1 reload with new content via Ajax. Use control+alt+0 to jump to box 4 and control+alt+L again to update the content there. This shows how keyboard accessibility can be implemented to map key combinations to rich internet application behaviors.
  3. For keyboard only users, moving focus is very important because that is the content which will have action taken on it or be the stepping off place for the next target in the tab order. For sighted users it might be hard to discern where focus has moved so make use of the Inspect32 tool. This simple tool puts a gold box around whatever currently has focus. You can obtain Inspect32 as part of the Microsoft's Active Accessibility 2.0 SDK Tools. Once Inspect32 is running with "Show highlight rectangle" turned on you can hit the control+alt+7 control+alt+8 control+alt+9 and control+alt+0 keys to see focus and the gold box hop to different boxes. If you use control+alt+L you should see the focused box get new content ajaxed in and focus move to the hidden header text to be read by a screen reader.
  4. To see what it's like to navigate via voice, you can use a screen reader like JAWS, from Freedom Scientific. More information and fully functional demo download for JAWS can be found at http://www.freedomscientific.com/fs_products/software_jaws.asp. Once you are up and running with JAWS load up the test page from the URL (not just hitting F5) and hit control+alt+8 to focus on the Box 2 and you should hear it read "Another blob of text in Box 2." Hit control+alt+9 and it should read what's in box 3. Hit control+alt+L and you should see box 3 reload and focus move to the hidden heading on the new content. Hit the down arrow and it should read out the text. This shows what can be done to use access technology for navigating a rich internet application.
Get Elements By Class Name
This is the JavaScript method they forgot in older browsers so we made one for you. It will use the native functionality if your browser supports it or use our own algorithm if your browser doesn't. In our demo we have 3000 hidden DIVs on the page (our haystack of DOM nodes) with five of them assigned the class "needle". Calling axs.gecn will return an array with the needles. On browsers like IE this takes about 16ms to execute because it doesn't have native support. On browsers like Firefox it takes about 1ms using the native function. This is great for gathering collections of DOM nodes you want to group together and have JavaScript do something to them.
Flash XOXO
Flash is great for many things but it can be troublesome for many because of issues with accessibility, high contrast, plugin versions and complex embedding code. The axs.flash_xoxo method give you a lot of flexibility in providing a method to progressivley enhance your page while providing a simple Microformat for all the Flash parameters needed to embed Flash on the page. On our demo page you can see that the code needed to embed a flash element has been reduced to little more than a definition list, something any HTML author can code. These definition lists can remain hidden and then used for progressive enhancement. On the demo page we change the last item into flash by simply calling axs.flash_xoxo which by default replaces any definition lists with a class of axs_flash_xoxo into the equivalent flash objet embed code. To change both HTMLs to flash we call axs.flash_xoxo({c:"xoxo",p:1}) which says to search for definition lists of class xoxo and replace their parent with the equivalent flash object/embed. the change the second HTML to flash we call axs.flash_xoxo({o:spot,c:"xoxo",r:spot}). The o parameter limits the search to definition lists found within the spot object. In this case spot is defined as the DOM node with an ID of moreFlashStuff. The last example is to change only the first HTML item to flash. This one we do simply with axs.flash_xoxo({c:"first",p:1}) which searches for a definition list of class first which happens to be the first HTML widget on the page. Setting p to 1 says to replace the parent of the xoxo list with the flash object embed.
High Contrast Detect
This simple demo shows how we can detect Windows high contrast mode. It simply calls axs.hd() which returns a true/false value. We use that to choose whether to append "on" or "off" to the end of the results statement and then updated the box with that statement. Like they Keycap demo, we blur focus, updated the content and then put focus on the box so the screen reader will notice the update. We also embed a hidden h6 tag which many screen readers will announce without extra keystrokes. In our H6 tag we simply put the text "Updated Results" wrapped in a span with a class that has off-screen text hiding CSS associated with it.
Flash Detect
For many things you might need to know what version of flash is installed to make sure that it will work and/or support accessible features you require. While the object/embedd lets you present alternate HTML, you might also have JS that has a need to know. You might even want to know before doing a progressive enhancement via axs.flash_xoxo. Flash version insight an be obtained by simply calling axs.fd() which returns the integer value such as 7, 8 or 9. The method includes min and max filter limits so you can use this to test for specific versions. axs.fd() returns 0 if no flash or no flash of the desired version is found. The demo page simply logs the results of calling axs.fd() on your particular browser.
MSAA Detect
This is a powerful yet dangerous method which will tell you if there is something using the MSAA APIs such as a screen reader. It's dangerous because some folks might be tempted to present alternative navigation by default if MSAA is in use when the user may not really want it. In other words it could be used to implement a demarcation between a "regular" or "accessible" version of your web app which is a slippery slope down to separate but equal implementations. The intention is actually to give your app insight into the possibility of a user having some kind of AT hooked into MSAA so that you might prompt the user to choose alternative navigation, presentation or other preferences. Automatic branching based on MSAA detection is discouraged. That said, the demo does what it says. It makes a call to axs.md(sr_result) which means when the detect completes it calls sr_result and passes it the result from the detection. We did this two stage callback system because detection can take a non-trivial amount of time to execute, sometimes up to 600ms. You can have other things getting their work done while waiting on the callback.

Methods

This library has been written to be compact and easy to integrate. All methods and globals are hung off the common axs object to avoid namespace collisions. The library is liberally commented with inputs for each method and is written in the form of a terse array of object methods for compactness. It also uses wrapper functions to reduce the size of the code. All user-facing strings are exposed in the axs.l10n structure to be easily overwritten for localization. This includes the control+alt+h key combination and its description. What follows is a method by method explanation of the entire library.
Primary Methods
Secondary Methods
This has been tested on Safari 3.2.1 and Firefox 3.0.7 on OSX 10.5 and Firefox 3.0.7, IE 7.0.5730.13 and Safari 3.2.2 on WinXP SP2 and has no known bugs.
Copyright (c) 2007-2009, AOL LLC
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.