From e8bcf08c72a18b3bf396e6448d6658227ecb46f2 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Wed, 30 Apr 2014 16:21:29 +0200 Subject: 1. Prepare core and Larry skin for improved accessibility 2. Implement full keyboard navigation in main mail view --- program/js/treelist.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'program/js/treelist.js') diff --git a/program/js/treelist.js b/program/js/treelist.js index 353eb6be7..0dbedd256 100644 --- a/program/js/treelist.js +++ b/program/js/treelist.js @@ -105,6 +105,8 @@ function rcube_treelist_widget(node, p) } }); + container.attr('role', 'tree'); + /////// private methods @@ -425,6 +427,9 @@ function rcube_treelist_widget(node, p) selection = node.id; } + // declare list item as treeitem + li.attr('role', 'treeitem'); + result.push(node); indexbyid[node.id] = node; }) -- cgit v1.2.3 From eb95518ef9b1bf9160f0e95d45811a4ef8c0e1fb Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Thu, 1 May 2014 10:54:45 +0200 Subject: Enable keyboard navigation on treelist widgets with cursor keys --- program/js/treelist.js | 93 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 4 deletions(-) (limited to 'program/js/treelist.js') diff --git a/program/js/treelist.js b/program/js/treelist.js index 0dbedd256..fa3907894 100644 --- a/program/js/treelist.js +++ b/program/js/treelist.js @@ -52,6 +52,7 @@ function rcube_treelist_widget(node, p) indexbyid = {}, selection = null, drag_active = false, + has_focus = false, box_coords = {}, item_coords = [], autoexpand_timer, @@ -105,8 +106,19 @@ function rcube_treelist_widget(node, p) } }); + container.on('focusin', function(e){ + // TODO: only accept focus on virtual nodes from keyboard events + has_focus = true; + }) + .on('focusout', function(e){ + has_focus = false; + }); + container.attr('role', 'tree'); + $(document.body) + .bind('keydown', keypress); + /////// private methods @@ -156,13 +168,13 @@ function rcube_treelist_widget(node, p) function select(id) { if (selection) { - id2dom(selection).removeClass('selected'); + id2dom(selection).removeClass('selected').removeAttr('aria-selected'); selection = null; } var li = id2dom(id); if (li.length) { - li.addClass('selected'); + li.addClass('selected').attr('aria-selected', 'true'); selection = id; // TODO: expand all parent nodes if collapsed scroll_to_node(li); @@ -368,6 +380,7 @@ function rcube_treelist_widget(node, p) var li = $('
  • ') .attr('id', p.id_prefix + (p.id_encode ? p.id_encode(node.id) : node.id)) + .attr('role', 'treeitem') .addClass((node.classes || []).join(' ')); if (replace) @@ -388,7 +401,7 @@ function rcube_treelist_widget(node, p) // add child list and toggle icon if (node.children && node.children.length) { $('
     
    ').appendTo(li); - var ul = $('