From d2bf33b242e9578fcb05bbf1365eeaf1d0dac67c Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 07 May 2014 06:44:10 -0400
Subject: [PATCH] Forward keyboard event through 'menu-open' command to enable keyboard navigation

---
 program/js/app.js |    2 +-
 skins/larry/ui.js |   17 ++++++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index f0aadd9..fecd5a0 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -711,7 +711,7 @@
         }
 
       case 'menu-save':
-        this.triggerEvent(command, {props:props});
+        this.triggerEvent(command, {props:props, e:event});
         return false;
 
       case 'open':
diff --git a/skins/larry/ui.js b/skins/larry/ui.js
index 9006b35..8476d91 100644
--- a/skins/larry/ui.js
+++ b/skins/larry/ui.js
@@ -160,7 +160,10 @@
 
         // add menu link for each attachment
         $('#attachment-list > li').each(function() {
-          $(this).append($('<a class="drop"></a>').click(function() { attachmentmenu(this); }));
+          $(this).append($('<a class="drop" tabindex="0" aria-haspopup="true">Show options</a>')
+              .click(function(e) { attachmentmenu(this, e); return false; })
+              .keypress(function(e){ if (rcube_event.get_keycode(e) == 13) attachmentmenu(this, e); return false; })
+          );
         });
 
         if (get_pref('previewheaders') == '1') {
@@ -491,7 +494,7 @@
     $('#message-objects div a').addClass('button');
 
     if (!$('#attachment-list li').length) {
-      $('div.rightcol').hide();
+      $('div.rightcol').hide().attr('aria-hidden', 'true');
       $('div.leftcol').css('margin-right', '0');
     }
   }
@@ -652,12 +655,12 @@
       ref.focus();
     }
 
-    obj[show?'show':'hide']();
+    obj[show?'show':'hide']().attr('aria-hidden', show?'false':'true');
 
     popup_keyboard_active = show && keyboard;
     if (popup_keyboard_active) {
       focused_popup = popup;
-      obj.find('a,input').not('[aria-disabled=true]').first().focus();
+      obj.find('a,input:not(:disabled)').not('[aria-disabled=true]').first().focus();
     }
     else {
       focused_popup = null;
@@ -819,7 +822,7 @@
   function menu_open(p)
   {
     if (p && p.props && p.props.menu == 'attachmentmenu')
-      show_popupmenu('attachmentmenu');
+      show_popupmenu('attachmentmenu', true, rcube_event.is_keyboard(p.e));
     else
       show_listoptions();
   }
@@ -863,7 +866,7 @@
     }
   }
 
-  function attachmentmenu(elem)
+  function attachmentmenu(elem, event)
   {
     var id = elem.parentNode.id.replace(/^attach/, '');
 
@@ -876,7 +879,7 @@
     });
 
     popupconfig.attachmentmenu.link = elem;
-    rcmail.command('menu-open', {menu: 'attachmentmenu', id: id});
+    rcmail.command('menu-open', {menu: 'attachmentmenu', id: id}, elem, event);
   }
 
   function spellmenu(show)

--
Gitblit v1.9.1