From 228a9ca69b3ea5738d04b85af91378a678e19c88 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Tue, 29 Nov 2011 12:33:02 +0100 Subject: [PATCH] [accessibility] restructured code fixed bug on keypress return click event triggers on return --- assets/javascripts/reporting/group_bys.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/reporting/group_bys.js b/assets/javascripts/reporting/group_bys.js index 7baebe08e9..4c93620bce 100644 --- a/assets/javascripts/reporting/group_bys.js +++ b/assets/javascripts/reporting/group_bys.js @@ -48,14 +48,23 @@ Reporting.GroupBys = { if (Reporting._LA != undefined) { button.setAttribute('title', Reporting._LA["REMOVE"] + ' ' + group_by.down('label').innerHTML); } - button.observe('mousedown', function() { Reporting.GroupBys.remove_group_by(button.up('.group_by_element')) }); + button.observe('click', function(e) { + Reporting.GroupBys.remove_element_event_action(e, group_by, button) + }); button.observe('keypress', function(e) { - var node; - if (e.keyCode == Event.KEY_RETURN || e.keyCode == 32) { + /* keyCode 32: Space */ + if (e.keyCode == 32) { e.preventDefault(); + Reporting.GroupBys.remove_element_event_action(e, group_by, button) + } + }); + return button; + }, + remove_element_event_action: function(event, group_by, button) { + var node; if (node = group_by.next('span')) { - node = node.down('button'); + node = node.down('a'); if (node) { node.focus(); } @@ -64,9 +73,6 @@ Reporting.GroupBys = { node.focus(); } Reporting.GroupBys.remove_group_by(button.up('.group_by_element')); - } - }); - return button; }, create_arrow: function(group_by, position) {