lib/pagy/extras/bulma.rb in pagy-5.7.1 vs lib/pagy/extras/bulma.rb in pagy-5.7.2

- old
+ new

@@ -5,11 +5,11 @@ class Pagy # :nodoc: # Frontend modules are specially optimized for performance. # The resulting code may not look very elegant, but produces the best benchmarks module BulmaExtra - # Pagination for Bulma: it returns the html with the series of links to the pages + # Pagination for bulma: it returns the html with the series of links to the pages def pagy_bulma_nav(pagy, pagy_id: nil, link_extra: '', **vars) p_id = %( id="#{pagy_id}") if pagy_id link = pagy_link_proc(pagy, link_extra: link_extra) html = +%(<nav#{p_id} class="pagy-bulma-nav pagination is-centered" aria-label="pagination">) @@ -28,10 +28,11 @@ end end html << %(</ul></nav>) end + # Javascript pagination for bulma: it returns a nav and a JSON tag used by the Pagy.nav javascript def pagy_bulma_nav_js(pagy, pagy_id: nil, link_extra: '', **vars) sequels = pagy.sequels(**vars) p_id = %( id="#{pagy_id}") if pagy_id link = pagy_link_proc(pagy, link_extra: link_extra) tags = { 'before' => %(#{pagy_bulma_prev_next_html(pagy, link)}<ul class="pagination-list">), @@ -45,21 +46,21 @@ %(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-bulma-nav-js pagination is-centered" aria-label="pagination" #{ pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>) end - # Javascript combo pagination for Bulma: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript + # Javascript combo pagination for bulma: it returns a nav and a JSON tag used by the pagy.js file def pagy_bulma_combo_nav_js(pagy, pagy_id: nil, link_extra: '') p_id = %( id="#{pagy_id}") if pagy_id link = pagy_link_proc(pagy, link_extra: link_extra) p_page = pagy.page p_pages = pagy.pages input = %(<input class="input" type="number" min="1" max="#{p_pages}" value="#{ p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length + 1}rem; margin:0 0.3rem;">) html = %(<nav#{p_id} class="pagy-bulma-combo-nav-js" aria-label="pagination">) %(#{html}<div class="field is-grouped is-grouped-centered" role="group" #{ - pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)}>#{ + pagy_json_attr pagy, :combo, pagy_marked_link(link)}>#{ if (p_prev = pagy.prev) %(<p class="control">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'class="button" aria-label="previous page"'}</p>) else %(<p class="control"><a class="button" disabled>#{pagy_t 'pagy.nav.prev'}</a></p>) end