[Pagination] Add a way to quickly travel to specific pages (#873)

This commit is contained in:
Cinder 2025-02-03 08:30:09 -08:00 committed by GitHub
parent 654023250f
commit d16361a926
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -74,7 +74,7 @@ module PaginationHelper
html = "".html_safe
if page == "..."
html << tag.li(class: "more") { tag.i(class: "fa-solid fa-ellipsis") }
html << tag.li(class: "more") { link_to(tag.i(class: "fa-solid fa-ellipsis"), nav_params_for(0)) }
elsif page == records.current_page
html << tag.li(class: "current-page") { tag.span(page) }
else

View File

@ -0,0 +1,19 @@
const Paginator = {};
Paginator.init_fasttravel = function (button) {
button.on("click", (event) => {
event.preventDefault();
const value = prompt("Navigate to page");
if (!value) return;
window.location.replace(button.attr("href").replace("page=0", "page=" + value));
});
};
$(() => {
for (const one of $(".paginator li.more a").get())
Paginator.init_fasttravel($(one));
});
export default Paginator;