[accessibility] restructured code

fixed bug on keypress return
click event triggers on return
pull/6827/head
Romano Licker 13 years ago
parent 548ee22f50
commit 228a9ca69b
  1. 20
      assets/javascripts/reporting/group_bys.js

@ -48,14 +48,23 @@ Reporting.GroupBys = {
if (Reporting._LA != undefined) { if (Reporting._LA != undefined) {
button.setAttribute('title', Reporting._LA["REMOVE"] + ' ' + group_by.down('label').innerHTML); 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) { button.observe('keypress', function(e) {
var node; /* keyCode 32: Space */
if (e.keyCode == Event.KEY_RETURN || e.keyCode == 32) { if (e.keyCode == 32) {
e.preventDefault(); 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')) { if (node = group_by.next('span')) {
node = node.down('button'); node = node.down('a');
if (node) { if (node) {
node.focus(); node.focus();
} }
@ -64,9 +73,6 @@ Reporting.GroupBys = {
node.focus(); node.focus();
} }
Reporting.GroupBys.remove_group_by(button.up('.group_by_element')); Reporting.GroupBys.remove_group_by(button.up('.group_by_element'));
}
});
return button;
}, },
create_arrow: function(group_by, position) { create_arrow: function(group_by, position) {

Loading…
Cancel
Save