diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-08-01 09:42:08 -0700 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-08-01 09:42:08 -0700 |
commit | 301f606fd81604b858381a13d0a0359de10ff561 (patch) | |
tree | ff108e36310e1c3e236dd16093a09ac77deaf941 /lib/scripts/tree.js | |
parent | 65f0aa62806695ee51cc94679913449b7ad862d6 (diff) | |
parent | 9805efa058358e0fcbd3976fa553901cabe0b2e0 (diff) | |
download | rpg-301f606fd81604b858381a13d0a0359de10ff561.tar.gz rpg-301f606fd81604b858381a13d0a0359de10ff561.tar.bz2 |
Merge pull request #248 from splitbrain/aria
Implemented some ARIA attributes
Diffstat (limited to 'lib/scripts/tree.js')
-rw-r--r-- | lib/scripts/tree.js | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/scripts/tree.js b/lib/scripts/tree.js index 96763053d..c4e1da3f7 100644 --- a/lib/scripts/tree.js +++ b/lib/scripts/tree.js @@ -14,6 +14,12 @@ jQuery.fn.dw_tree = function(overrides) { init: function () { this.$obj.delegate(this.toggle_selector, 'click', this, this.toggle); + jQuery('ul:first', this.$obj).attr('role', 'tree'); + jQuery('ul', this.$obj).not(':first').attr('role', 'group'); + jQuery('li', this.$obj).attr('role', 'treeitem'); + jQuery('li.open > ul', this.$obj).attr('aria-expanded', 'true'); + jQuery('li.closed > ul', this.$obj).attr('aria-expanded', 'false'); + jQuery('li.closed', this.$obj).attr('aria-live', 'assertive'); }, /** @@ -35,8 +41,14 @@ jQuery.fn.dw_tree = function(overrides) { $listitem = $clicky.closest('li'); $sublist = $listitem.find('ul').first(); opening = $listitem.hasClass('closed'); - $listitem.toggleClass('open closed'); dw_tree.toggle_display($clicky, opening); + if ($sublist.is(':visible')) { + $listitem.removeClass('open').addClass('closed'); + $sublist.attr('aria-expanded', 'false'); + } else { + $listitem.removeClass('closed').addClass('open'); + $sublist.attr('aria-expanded', 'true'); + } // if already open, close by hiding the sublist if (!opening) { @@ -48,6 +60,8 @@ jQuery.fn.dw_tree = function(overrides) { $sublist.hide(); if (typeof data !== 'undefined') { $sublist.html(data); + $sublist.parent().attr('aria-busy', 'false').removeAttr('aria-live'); + jQuery('li.closed', $sublist).attr('aria-live', 'assertive'); } if ($listitem.hasClass('open')) { // Only show if user didn’t close the list since starting @@ -63,11 +77,11 @@ jQuery.fn.dw_tree = function(overrides) { } //prepare the new ul - $sublist = jQuery('<ul class="idx"/>'); + $sublist = jQuery('<ul class="idx" role="group"/>'); $listitem.append($sublist); timeout = window.setTimeout( - bind(show_sublist, '<li><img src="' + DOKU_BASE + 'lib/images/throbber.gif" alt="loading..." title="loading..." /></li>'), dw_tree.throbber_delay); + bind(show_sublist, '<li aria-busy="true"><img src="' + DOKU_BASE + 'lib/images/throbber.gif" alt="loading..." title="loading..." /></li>'), dw_tree.throbber_delay); dw_tree.load_data(function (data) { window.clearTimeout(timeout); |