Make pagination padding clickable again #40

Merged
Roflin merged 3 commits from page-wildcards into master 2023-11-22 16:03:48 +01:00
2 changed files with 22 additions and 1 deletions
Showing only changes of commit 230c65478f - Show all commits

View File

@ -75,6 +75,9 @@ a:hover {
.pagination .page-item {
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
}
.pagination .wildcard {
cursor: pointer;
}
@media (max-width: 767px) {
.pagination {

View File

@ -11,6 +11,8 @@ class PageIndexWidget extends Template
private $index;
private string $class;
private static $unique_index_count = 0;
public function __construct(PageIndex $index)
{
$this->index = $index;
@ -37,14 +39,18 @@ class PageIndexWidget extends Template
'<a class="page-link"', !empty($page_index['previous']) ? ' href="' . $page_index['previous']['href'] . '"' : '', '>',
'&laquo; previous</a></li>';
$num_wildcards = 0;
foreach ($page_index as $key => $page)
{
if (!is_numeric($key))
continue;
if (!is_array($page))
{
$num_wildcards++;
echo '
<li class="page-item page-padding disabled"><a class="page-link">...</a></li>';
<li class="page-item page-padding wildcard" onclick="javascript:promptGoToPage(', self::$unique_index_count, ')"><a class="page-link">...</a></li>';
}
else
echo '
<li class="page-item page-number', $page['is_selected'] ? ' active" aria-current="page' : '', '">',
@ -56,5 +62,17 @@ class PageIndexWidget extends Template
'<a class="page-link"', !empty($page_index['next']) ? ' href="' . $page_index['next']['href'] . '"' : '', '>',
'next &raquo;</a></li>
</ul>';
if ($num_wildcards)
{
echo '
<script type="text/javascript">
var page_index_', self::$unique_index_count++, ' = {
wildcard_url: "', $index->getLink("%d"), '",
num_pages: ', $index->getNumberOfPages(), ',
per_page: ', $index->getItemsPerPage(), '
};
</script>';
}
}
}