Skip to content

a11y: entry stream pagination #1135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,14 @@ input {
display:none;
}

#stream-pagination {
text-align: center;
}

#stream-pagination li {
display: inline;
}

#fullscreen-entry {
display:none;
}
Expand Down
16 changes: 13 additions & 3 deletions public/js/selfoss-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,19 +559,29 @@ selfoss.dbOffline = {
var isMore = false;
var alwaysInDb = selfoss.filter.type === 'starred'
|| selfoss.filter.type === 'unread';
var offset = selfoss.filter.offset;

entries.filter(function(entry) {
var keepEntry = false;

if (selfoss.filter.extraIds.indexOf(entry.id) > -1) {
return true;
}

if (selfoss.filter.type == 'starred') {
return entry.starred;
keepEntry = entry.starred;
} else if (selfoss.filter.type == 'unread') {
return entry.unread;
keepEntry = entry.unread;
} else if (selfoss.filter.type == 'lastread') {
keepEntry = !entry.unread && !entry.skipped;
}

if (keepEntry && offset > 0) {
offset = offset - 1;
return false;
}

return true;
return keepEntry;
}).until(function(entry) {
// stop iteration if enough entries have been shown
// go one further to assess if has more
Expand Down
7 changes: 7 additions & 0 deletions public/js/selfoss-events-entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ selfoss.events.entries = function() {
});
}

// stream pagination buttons
$('#stream-pagination button').unbind('click').click(function() {
var pageNumber = parseInt($(this).html());
selfoss.filter.offset = (pageNumber - 1) * selfoss.filter.itemsPerPage;
selfoss.db.reloadList();
});

// click a tag
if (selfoss.isSmartphone() == false) {
$('.entry-tags-tag').unbind('click').click(function() {
Expand Down
15 changes: 15 additions & 0 deletions public/js/selfoss-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ selfoss.ui = {
if (hasMore) {
$('.stream-more').show();
}

var streamPagination = $('#stream-pagination').empty();
var count = parseInt($('.nav-filter-' + selfoss.filter.type +
' span.count').html());
for (var pageNumber = 1;
pageNumber < count / selfoss.filter.itemsPerPage + 1;
pageNumber++) {
var currentAttr = '';
var current = '';
if (selfoss.filter.offset == selfoss.filter.itemsPerPage * (pageNumber - 1)) {
currentAttr = ' aria-current="true"';
current = ' (current)';
}
streamPagination.append('<li><button aria-label="Goto Page ' + pageNumber + '"' + currentAttr + '>' + pageNumber + current + '</button></li>');
}
} else {
$('.stream-empty').show();
if (selfoss.isSmartphone()) {
Expand Down
3 changes: 3 additions & 0 deletions templates/home.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@
<button class="stream-button stream-more"><span><?= trim(\F3::get('lang_more')); ?></span></button>
<button class="stream-button mark-these-read"><span><?= trim(\F3::get('lang_markread')); ?></span></button>
<button class="stream-button stream-error"><?= trim(\F3::get('lang_streamerror')); ?></button>
<nav role="navigation" aria-label="Pagination Navigation">
<ul id="stream-pagination" />
</nav>
</div>

<!-- fullscreen popup -->
Expand Down