diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2014-05-12 10:32:45 +0200 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2014-05-12 10:32:45 +0200 |
commit | a2f8fa236143b44f90e53c19806cfd0efa014857 (patch) | |
tree | fcd5c1d586568c0fcd06fe57bdb6ba7a62d8d484 /program | |
parent | 93cd38af7dc7a361af488478c31e946a0c5ea10c (diff) |
Set aria-selected and aria-expanded state attributes
Diffstat (limited to 'program')
-rw-r--r-- | program/js/app.js | 8 | ||||
-rw-r--r-- | program/js/list.js | 12 | ||||
-rw-r--r-- | program/js/treelist.js | 13 |
3 files changed, 19 insertions, 14 deletions
diff --git a/program/js/app.js b/program/js/app.js index dd172cd99..06008b2da 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -6967,7 +6967,7 @@ function rcube_webmail() this.hide_menu(this.menu_stack[0], event); } - obj.show().attr('aria-hidden', 'false').data('opener', ref.get(0)); + obj.show().attr('aria-hidden', 'false').data('opener', ref.attr('aria-expanded', 'true').get(0)); this.triggerEvent('menu-open', { name:name, obj:obj, props:prop, originalEvent:event }); this.menu_stack.push(name); @@ -6999,8 +6999,10 @@ function rcube_webmail() this.triggerEvent('menu-close', { name:this.menu_stack[j], obj:obj, props:{ menu:this.menu_stack[j] }, originalEvent:event }); if (this.menu_stack[j] == name) { j = -1; // stop loop - if (keyboard && obj.data('opener')) { - obj.data('opener').focus(); + if (obj.data('opener')) { + $(obj.data('opener')).attr('aria-expanded', 'false'); + if (keyboard) + obj.data('opener').focus(); } } this.menu_stack.pop(); diff --git a/program/js/list.js b/program/js/list.js index fa37353e8..f64d38bc3 100644 --- a/program/js/list.js +++ b/program/js/list.js @@ -116,7 +116,7 @@ init: function() this.focus_elem = $('<a>') .attr('tabindex', '0') .attr('style', 'display:block; width:1px; height:1px; line-height:1px; overflow:hidden; position:fixed; top:-1000px') - .html('Select List') + .html($(this.list).attr('summary') || 'Select List') .insertAfter(this.list) .on('focus', function(e){ me.focus(e); }) .on('blur', function(e){ me.blur(e); }); @@ -1086,7 +1086,7 @@ select_all: function(filter) this.highlight_row(n, true, true); } else { - $(this.rows[n].obj).removeClass('selected').removeClass('unfocused'); + $(this.rows[n].obj).removeClass('selected').removeClass('unfocused').removeAttr('aria-selected'); } } @@ -1143,7 +1143,7 @@ clear_selection: function(id, no_event) else { for (n in this.selection) if (this.rows[this.selection[n]]) { - $(this.rows[this.selection[n]].obj).removeClass('selected').removeClass('unfocused'); + $(this.rows[this.selection[n]].obj).removeClass('selected').removeClass('unfocused').removeAttr('aria-selected'); } this.selection = []; @@ -1206,13 +1206,13 @@ highlight_row: function(id, multiple, norecur) if (this.selection.length > 1 || !this.in_selection(id)) { this.clear_selection(null, true); this.selection[0] = id; - $(this.rows[id].obj).addClass('selected'); + $(this.rows[id].obj).addClass('selected').attr('aria-selected', 'true'); } } else { if (!this.in_selection(id)) { // select row this.selection.push(id); - $(this.rows[id].obj).addClass('selected'); + $(this.rows[id].obj).addClass('selected').attr('aria-selected', 'true'); if (!norecur && !this.rows[id].expanded) this.highlight_children(id, true); } @@ -1222,7 +1222,7 @@ highlight_row: function(id, multiple, norecur) a_post = this.selection.slice(p+1, this.selection.length); this.selection = a_pre.concat(a_post); - $(this.rows[id].obj).removeClass('selected').removeClass('unfocused'); + $(this.rows[id].obj).removeClass('selected').removeClass('unfocused').removeAttr('aria-selected'); if (!norecur && !this.rows[id].expanded) this.highlight_children(id, false); } diff --git a/program/js/treelist.js b/program/js/treelist.js index fa3907894..8b55b32b1 100644 --- a/program/js/treelist.js +++ b/program/js/treelist.js @@ -323,7 +323,7 @@ function rcube_treelist_widget(node, p) */ function update_data() { - data = walk_list(container); + data = walk_list(container, 0); } /** @@ -332,6 +332,7 @@ function rcube_treelist_widget(node, p) function update_dom(node) { var li = id2dom(node.id); + li.attr('aria-expanded', node.collapsed ? 'false' : 'true'); li.children('ul').first()[(node.collapsed ? 'hide' : 'show')](); li.children('div.treetoggle').removeClass('collapsed expanded').addClass(node.collapsed ? 'collapsed' : 'expanded'); me.triggerEvent('toggle', node); @@ -400,8 +401,9 @@ function rcube_treelist_widget(node, p) // add child list and toggle icon if (node.children && node.children.length) { + li.attr('aria-expanded', node.collapsed ? 'false' : 'true'); $('<div class="treetoggle '+(node.collapsed ? 'collapsed' : 'expanded') + '"> </div>').appendTo(li); - var ul = $('<ul>').appendTo(li).attr('class', node.childlistclass).attr('role', 'tree'); + var ul = $('<ul>').appendTo(li).attr('class', node.childlistclass).attr('role', 'group'); if (node.collapsed) ul.hide(); @@ -417,7 +419,7 @@ function rcube_treelist_widget(node, p) * Recursively walk the DOM tree and build an internal data structure * representing the skeleton of this tree list. */ - function walk_list(ul) + function walk_list(ul, level) { var result = []; ul.children('li').each(function(i,e){ @@ -427,7 +429,7 @@ function rcube_treelist_widget(node, p) classes: li.attr('class').split(' '), virtual: li.hasClass('virtual'), html: li.children().first().get(0).outerHTML, - children: walk_list(sublist) + children: walk_list(sublist, level+1) } if (sublist.length) { @@ -435,6 +437,7 @@ function rcube_treelist_widget(node, p) } if (node.children.length) { node.collapsed = sublist.css('display') == 'none'; + li.attr('aria-expanded', node.collapsed ? 'false' : 'true'); } if (li.hasClass('selected')) { li.attr('aria-selected', 'true'); @@ -453,7 +456,7 @@ function rcube_treelist_widget(node, p) indexbyid[node.id] = node; }); - ul.attr('role', 'tree'); + ul.attr('role', level == 0 ? 'tree' : 'group'); return result; } |