Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow page select when clicking pagination ellipsis (#614)
* This allows users to modify the pagination style. * refactor: fix PHP styling * Never mind, guess I figured it out. * refactor: fix blade formatting * Forgot to remove this test. Whoops. * refactor: fix blade formatting * Simplified the quick pagination code some * Put the number input back because it's nice to type a number * refactor: fix blade formatting * Added credits didn't intend to when it was just me, but Moif deserves this * Minor update to credits- fixing up wiki pages. --------- Co-authored-by: SpeedyD <SpeedyD@users.noreply.github.com> Co-authored-by: moif <moiftab@gmail.com>
- Loading branch information
1 parent
6c87c42
commit 5b411fe
Showing
7 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
@if ($paginator->hasPages()) | ||
<nav> | ||
<ul class="pagination"> | ||
{{-- Previous Page Link --}} | ||
@if ($paginator->onFirstPage()) | ||
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')"> | ||
<span class="page-link" aria-hidden="true">‹</span> | ||
</li> | ||
@else | ||
<li class="page-item"> | ||
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">‹</a> | ||
</li> | ||
@endif | ||
|
||
{{-- Pagination Elements --}} | ||
@foreach ($elements as $element) | ||
{{-- "Three Dots" Separator --}} | ||
@if (is_string($element)) | ||
<li class="page-item pageSelectPopover" data-container="body" data-toggle="popover" data-placement="top" data-title="Jump to Page" data-html="true" | ||
data-content=' | ||
<div class="pagination-popover d-flex align-items-center" style="gap: 10px;"> | ||
<input type="range" class="form-control-range custom-range paginationPageRange" min="1" max="{{ $paginator->lastPage() }}" value="{{ $paginator->currentPage() }}" oninput="this.nextElementSibling.value = this.value"> | ||
<input type="number" style="flex: 1 0 35px; height: 24px;" class="paginationPageText form-control form-control-sm py-0 px-1" min="1" max="{{ $paginator->lastPage() }}" value="{{ $paginator->currentPage() }}" oninput="this.previousElementSibling.value = this.value"> | ||
<span class="badge badge-primary paginator-btn p-1 px-2" style="cursor: pointer; font-size: 14px">Go</span> | ||
</div> | ||
'> | ||
<span class="page-link">{{ $element }}</span> | ||
</li> | ||
@endif | ||
|
||
{{-- Array Of Links --}} | ||
@if (is_array($element)) | ||
@foreach ($element as $page => $url) | ||
@if ($page == $paginator->currentPage()) | ||
<li class="page-item active" aria-current="page"><span class="page-link">{{ $page }}</span></li> | ||
@else | ||
<li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li> | ||
@endif | ||
@endforeach | ||
@endif | ||
@endforeach | ||
|
||
{{-- Next Page Link --}} | ||
@if ($paginator->hasMorePages()) | ||
<li class="page-item"> | ||
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')">›</a> | ||
</li> | ||
@else | ||
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')"> | ||
<span class="page-link" aria-hidden="true">›</span> | ||
</li> | ||
@endif | ||
</ul> | ||
</nav> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script> | ||
$('.pageSelectPopover').popover() | ||
function onClick(e) { | ||
const pageCurrent = new URL(window.location.href); | ||
pageCurrent.searchParams.set("page", e.currentTarget.parentElement.querySelector('.paginationPageRange').value); | ||
document.location.href = pageCurrent.href; | ||
} | ||
$('.pageSelectPopover').on('shown.bs.popover', function() { | ||
$('.paginator-btn').on('click', onClick); | ||
// so you can just hit enter after moving the range bar or entering a number | ||
$('.paginationPageRange').on('keypress', (e) => e.which === 13 && onClick(e)); | ||
$('.paginationPageText').on('keypress', (e) => e.which === 13 ? onClick(e) : true); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@if ($paginator->hasPages()) | ||
<nav> | ||
<ul class="pagination"> | ||
{{-- Previous Page Link --}} | ||
@if ($paginator->onFirstPage()) | ||
<li class="page-item disabled" aria-disabled="true"> | ||
<span class="page-link">@lang('pagination.previous')</span> | ||
</li> | ||
@else | ||
<li class="page-item"> | ||
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a> | ||
</li> | ||
@endif | ||
|
||
{{-- Next Page Link --}} | ||
@if ($paginator->hasMorePages()) | ||
<li class="page-item"> | ||
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('pagination.next')</a> | ||
</li> | ||
@else | ||
<li class="page-item disabled" aria-disabled="true"> | ||
<span class="page-link">@lang('pagination.next')</span> | ||
</li> | ||
@endif | ||
</ul> | ||
</nav> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters