3

Hello compliance pros!

I've been tasked with making our web-app compliant to the section 508 and wcag 2.0 guidlines. For most things this hasn't been too tricky, but i've hit a bit of a road block.

I use qtip a lot in the app, which tends to be mostly compliant b/c it uses the wai-aria role and described-by attributes. BUT, the way i add my tooltips makes it so they don't get put on the text until the first mouseover. which clearly isn't going to happen with keyboard navigation, and i'm not sure how screen readers wil handle that either!

I've made a fiddle here: http://jsfiddle.net/patriciavandermeer/xkhy6/2/ that demonstrates what i'm talking about. the tooltips are html that the end users can set elsewhere, and they list items may or may not have a tooltip.

i was thinking about making the tooltips be applied and show up on :focus(and hide on loss of focus), but then i'd need to give the span a tabindex and i'm not sure how well supported that is, can all the main browsers handle that ok?

or should i just bite the bullet and have the tooltips hooked up in the document ready? I had some serious performance issues on some of my busier pages when i had it set up that way.

EDIT: Here's a sample of the html that would be used, and the jquery/ javascript i use to attach the tooltips to the spans.

Sample HTML:

    <li >
        <span class="InteractiveToolTipMe">Administration</span>
        <div class="InteractiveToolTip NoDisplay"><p>This is a description</p>
            <p>&nbsp;</p>
            <p>For administration.....</p></div>

    </li>

    <li >
        Board and Committees
    </li>

    <li  >
        Community Outreach
    </li>
    <li  >
        <span class="InteractiveToolTipMe">Fundraising</span>
        <div class="InteractiveToolTip NoDisplay"><p><strong>test</strong></p>
            <p>&nbsp;</p>
            <ul>
                <li><strong>test</strong></li>
                <li>test</li>
                <li>test</li>
            </ul>
        </div>
    </li>
    <li  style="padding:2px;">
        Physics
    </li>

    <li  style="padding:2px;">
        Public Speaking
    </li>
    <li  style="padding:2px;">
        Special Events
    </li>
</ul>

Javascript for attaching the tooltips:

$('span.InteractiveToolTipMe').live("mouseover", function () {

        var $this = $(this);
        if (!$this.data("toolTipAttached")) {
            var content = $(this).parent().find('.InteractiveToolTip').html();

            $this.qtip({
                content: {
                    text: content
                },
                position: {
                    target: 'mouse',
                    adjust: {
                        mouse: false
                    },
                    viewport: $(window)
                },
                hide: {
                    fixed: true,
                    delay:350,
                    when: 'mouseout'
                },
                show: {

                    solo: true,
                    delay: 350,
                    ready: true
                },
                style: {
                    widget: true,
                    tip:false,
                    classes: "LegendTip"

                }
            });

            $this.data("toolTipAttached", true);
            //$this.trigger("mouseover");
        }

    });
JJJ
  • 32,902
  • 20
  • 89
  • 102
Patricia
  • 7,752
  • 4
  • 37
  • 70

1 Answers1

3

WOW! First of all, your code froze my browser. I'm not sure if this the fault of JSFiddle or your code. If you show me the a live page with your code in it I could check it out there.

As far as accessibility goes, I would choose the :focus approach, where all your tooltips exist on the page after page load. This makes access to your tooltip data by screen readers very simple. Also:

  • You won't need to load any data via AJAX (I assume that's what you're doing), which may cut down on latency if you're making a lot of requests
  • You won't have to come up with a way to alert screen readers that new tooltip content has been loaded (blind readers probably won't be expecting it)

It looks like your tooltips are associated with anchors. If you markup your tooltip divs/spans with class aToolTip, you can 'hide' them when the associated anchor is not focused:

a + .aToolTip {
  position: absolute;
  left:-999em;
}

Then you can 'show' your tooltips when the anchor preceding it is focused or hovered:

a:hover + .aToolTip,
a:focus + .aToolTip {
  position: static;
  left:0;
}

If the display of the tooltip depends on an anchor, you won't have to bother with tabIndex. Keep in mind the + operator is CSS3 only. Using JavaScript, you could come up with something similar that would work in more browsers.

One last idea to get the tooltip info to blind users: if you stuff it in the title attribute of your anchors, screen readers will read it along with the anchor text. Just try to keep it simple! :)

Hope that helped somewhat.

Jonathan Wilson
  • 4,138
  • 1
  • 24
  • 36
  • Be wary of title: I seem to remember some screen readers reading out title *instead* of the content, rather than in addition to; but also, title text is generally not keyboard accessible - be sure to keep sighted keyboard-only users in mind, in addition to screenreader users! – BrendanMcK Sep 17 '11 at 05:40
  • The title text is _not_ keyboard accessible. – Jonathan Wilson Sep 17 '11 at 10:57
  • Thanks for the answer Jonathan! Strange that my sample page crashed your browser! my tooltips arn't ussually associated with links, in this case, it's just a list of things, which may or may not have a long description. The descriptions are in the page, in a hidden div beside the text. I'll edit my question to show the markup that is in the fiddle. – Patricia Sep 19 '11 at 14:03
  • 1
    @Jonathan: i think your on to something with the links, if i add links to the text that has the tooltips, then they will get focus, and i can just make the link go to #. i think that's basically what your saying right? – Patricia Sep 19 '11 at 19:45
  • Yes, that's what I'm saying. The list items with tooltips _are_ eventually going to be links anyway, right? – Jonathan Wilson Sep 20 '11 at 18:07
  • Also, I tried your JSFiddle on my work machine--which is much more powerful than my home machine--and ran into the same sluggish behavior. I can't say for sure without seeing your code 'in the wild' but I think there is a major issue with your javascript... perhaps there is some recursion somewhere. – Jonathan Wilson Sep 20 '11 at 18:10
  • it runs fine in the wild, probably just something wonky in the jsfiddle. In this particular case, they arn't links, and won't be, i do have other tooltips on links though. I think i'll go with making them all (tooltip or not) links to #, then they can tab through the list, and ones with tooltips will then have there tooltip accessible. Thanks for your help :) – Patricia Sep 22 '11 at 13:08
  • No problem! Good luck on your project. – Jonathan Wilson Sep 23 '11 at 15:53