# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/materialize # frozen_string_literal: true require 'pagy/extras/shared' class Pagy module Frontend # Pagination for materialize: it returns the html with the series of links to the pages def pagy_materialize_nav(pagy) html, link, p_prev, p_next = +'', pagy_link_proc(pagy), pagy.prev, pagy.next html << (p_prev ? %() : %()) pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] html << if item.is_a?(Integer); %(
  • #{link.call item}
  • ) # page link elsif item.is_a?(String) ; %(
  • #{link.call item}
  • ) # active page elsif item == :gap ; %(
  • #{pagy_t('pagy.nav.gap')}
  • ) # page gap end end html << (p_next ? %() : %()) %() end Pagy.deprecate self, :pagy_nav_materialize, :pagy_materialize_nav # Compact pagination for materialize: it returns the html with the series of links to the pages # we use a numeric input tag to set the page and the Pagy.compact javascript to navigate def pagy_materialize_compact_nav(pagy, id=caller(1,1)[0].hash.to_s) html, link, p_prev, p_next, p_page, p_pages = +'', pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages html << %(