a11y: add support for foldable/folding cells (#38192)
This commit is contained in:
parent
904655c293
commit
43b6161159
|
@ -213,10 +213,38 @@ $(function() {
|
|||
$(checkboxes[checkboxes.length-1]).parents('tr').next().find('td:nth-child(' + (column_index+1) + ')').addClass('clickable');
|
||||
}
|
||||
|
||||
$('body').on('click', 'div.cell.foldable > div > h2:first-child, div.cell.foldable > div > picture', function() {
|
||||
$(this).parents('div.foldable').toggleClass('folded');
|
||||
/* foldable/folded support */
|
||||
function prepare_foldable(cell) {
|
||||
var $cell = $(cell);
|
||||
if (! $cell.is('.foldable')) {
|
||||
return;
|
||||
}
|
||||
var $cell_title = $cell.find('> div > h2:first-child');
|
||||
$cell_title.attr('tabindex', '0');
|
||||
$cell_title.attr('role', 'button');
|
||||
function set_aria_expanded() {
|
||||
if ($cell.is('.folded')) {
|
||||
$cell_title.attr('aria-expanded', 'false');
|
||||
} else {
|
||||
$cell_title.attr('aria-expanded', 'true');
|
||||
}
|
||||
}
|
||||
set_aria_expanded();
|
||||
$cell.find('> div > h2:first-child').on('keydown', function(ev) {
|
||||
if (ev.keyCode == 13 || ev.keyCode == 32) { // enter || space
|
||||
$(this).trigger('click');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$cell.find('> div > h2:first-child, > div > picture').on('click', function() {
|
||||
$cell.toggleClass('folded');
|
||||
set_aria_expanded();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$('div.cell.foldable').each(function(i, cell) { prepare_foldable(cell); });
|
||||
$(document).on('combo:cell-loaded', function(ev, cell) { prepare_foldable(cell); });
|
||||
|
||||
/* add a scrolled class to body once the user scrolled the page a bit */
|
||||
$(window).on('scroll', function() {
|
||||
|
|
Loading…
Reference in New Issue