lib/pagy/extras/materialize.rb in pagy-5.6.10 vs lib/pagy/extras/materialize.rb in pagy-5.7.0
- old
+ new
@@ -26,21 +26,22 @@
html << %(</ul></div>)
end
# Javascript pagination for materialize: it returns a nav and a JSON tag used by the Pagy.nav javascript
def pagy_materialize_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' => %(<ul class="pagination">#{pagy_materialize_prev_html pagy, link}),
'link' => %(<li class="waves-effect">#{mark = link.call(PAGE_PLACEHOLDER, LABEL_PLACEHOLDER)}</li>),
'active' => %(<li class="active">#{mark}</li>),
'gap' => %(<li class="gap disabled"><a href="#">#{pagy_t 'pagy.nav.gap'}</a></li>),
'after' => %(#{pagy_materialize_next_html pagy, link}</ul>) }
- %(<div#{p_id} class="pagy-njs pagy-materialize-nav-js" role="navigation" aria-label="pager" #{
- pagy_json_attr(pagy, :nav, tags, (sequels = pagy.sequels(**vars)), pagy.label_sequels(sequels))}></div>)
+ %(<div#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-materialize-nav-js" role="navigation" aria-label="pager" #{
+ pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></div>)
end
# Javascript combo pagination for materialize: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
def pagy_materialize_combo_nav_js(pagy, pagy_id: nil, link_extra: '')
p_id = %( id="#{pagy_id}") if pagy_id
@@ -51,10 +52,10 @@
input = %(<input type="number" class="browser-default" min="1" max="#{p_pages}" value="#{
p_page}" style="text-align: center; width: #{p_pages.to_s.length + 1}rem;">)
html = %(<ul#{p_id} class="pagy-materialize-combo-nav-js pagination chip" role="navigation")
%(#{html} aria-label="pager" style="padding-right: 0" #{
- pagy_json_attr pagy, :combo_nav, p_page, pagy_marked_link(link)}>#{
+ pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)}>#{
pagy_materialize_prev_html pagy, link, style}<li class="pagy-combo-input">#{
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages}</li>#{
pagy_materialize_next_html pagy, link, style}</ul>)
end