# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/bootstrap
# encoding: utf-8
# frozen_string_literal: true
require 'pagy/extras/shared'
class Pagy
module Frontend
# Pagination for bootstrap: it returns the html with the series of links to the pages
def pagy_bootstrap_nav(pagy)
link, p_prev, p_next = pagy_link_proc(pagy, 'class="page-link"'), pagy.prev, pagy.next
html = EMPTY + (p_prev ? %(
))
%()
end
# Javascript pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.nav javascript
def pagy_bootstrap_nav_js(pagy, id=pagy_id)
link, p_prev, p_next = pagy_link_proc(pagy, 'class="page-link"'), pagy.prev, pagy.next
tags = { 'before' => p_prev ? %(
) }
%(#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(TRIM) && pagy.vars[:page_param])})
end
# Javascript combo pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
def pagy_bootstrap_combo_nav_js(pagy, id=pagy_id)
link, p_prev, p_next, p_page, p_pages = pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages
html = %(#{pagy_json_tag(:combo_nav, id, p_page, pagy_marked_link(link), defined?(TRIM) && pagy.vars[:page_param])})
end
end
end