From d4d62ac414a3ba706fb65c581581c419a90d5ac9 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Tue, 27 May 2014 10:59:28 -0400
Subject: [PATCH] Set aria-* attributes for autocompletion fields and widgets

---
 program/js/list.js |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/program/js/list.js b/program/js/list.js
index fa37353..59651b8 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -116,7 +116,7 @@
       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); });
@@ -213,6 +213,7 @@
   if (!this.fixed_header) {
     this.fixed_header = $('<table>')
       .attr('class', this.list.className + ' fixedcopy')
+      .attr('role', 'presentation')
       .css({ position:'fixed' })
       .append(clone)
       .append('<tbody></tbody>');
@@ -1086,7 +1087,7 @@
       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 +1144,7 @@
   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 +1207,13 @@
     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 +1223,7 @@
         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);
     }

--
Gitblit v1.9.1