accessibility: replace focus at the beginning of list on pagination change (#41128)
This commit is contained in:
parent
510a5c114e
commit
ea510ca0f1
|
@ -363,13 +363,15 @@ $(function() {
|
|||
var paginate_by = parseInt($pagination.data('paginate-by'));
|
||||
// Get all <li> inside the same div as us, ignoring whether they are part of
|
||||
// different <ul>
|
||||
var wrapper = $pagination.parent();
|
||||
wrapper.attr('tabindex', -1)
|
||||
var items = $pagination.parent().find('li');
|
||||
var max_page_index = Math.ceil(items.length / paginate_by);
|
||||
if (items.length <= paginate_by) {
|
||||
return;
|
||||
}
|
||||
|
||||
function update_page(step) {
|
||||
function update_page(step, focus_first_item) {
|
||||
page_index = page_index + step;
|
||||
if (page_index == 0) {
|
||||
$pagination.find('.cell-items-pagination-prev').prop('disabled', true);
|
||||
|
@ -384,11 +386,14 @@ $(function() {
|
|||
start_item = paginate_by * page_index;
|
||||
items.hide();
|
||||
items.slice(start_item, start_item + paginate_by).show();
|
||||
if (focus_first_item) {
|
||||
wrapper.focus()
|
||||
}
|
||||
};
|
||||
|
||||
$pagination.find('.cell-items-pagination-prev').click(function() { update_page(-1); });
|
||||
$pagination.find('.cell-items-pagination-next').click(function() { update_page(1); });
|
||||
update_page(0);
|
||||
$pagination.find('.cell-items-pagination-prev').click(function() { update_page(-1, true); });
|
||||
$pagination.find('.cell-items-pagination-next').click(function() { update_page(1, true); });
|
||||
update_page(0, false);
|
||||
$pagination.prop('hidden', null);
|
||||
});
|
||||
$('.cell-items-pagination').each(function(idx, elem) {
|
||||
|
|
Loading…
Reference in New Issue