PageIndexWidget: restore wildcard functionality
This commit is contained in:
parent
2ec565242e
commit
230c65478f
@ -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 {
|
||||
|
@ -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'] . '"' : '', '>',
|
||||
'« 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 »</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>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user