Continuous pagination. Refs #24

This commit is contained in:
echarp 2016-01-10 14:41:20 +01:00
parent 3a5df0b521
commit bede2ce5e1
5 changed files with 38 additions and 5 deletions

View File

@ -0,0 +1,24 @@
# Automatic ajax pagination
$(document).ready ->
$('.pagination .next a')
.attr('data-remote', true)
.click ->
$('#loading').fadeIn()
$(document).on 'ajax:success', '.pagination .next a', (event, data, status, xhr) ->
$('#loading').fadeOut()
elts = $('tbody tr', data)
$(this).parents('tfoot').prev().append(elts)
next = $('.pagination .next a', data).attr('href')
if next?
return $(this).show().data('remote', true).attr('href', next)
else
return $(this).parents('.pagination').remove()
# Go to the next page when page is scrolled
if $('.pagination .next a').size() > 0
$(document).scroll ->
if $(window).scrollTop() == $(document).height() - $(window).height() && $('.pagination .next a').is(':visible')
# "Next" link is also hidden while pagination is done
$('.pagination .next a').hide().click()

View File

@ -268,6 +268,12 @@ footer.bottom nav
vertical-align: baseline
+text-shadow(0 0 4px gray)
.pagination
span
display: none
span.next
display: block
.select2-container ul
min-width: 46em
.select2-container-multi.select2-container-active .select2-choices, .select2-drop

View File

@ -59,4 +59,6 @@
= link_to edit_orga_path orga do
%em.fa.fa-pencil
= paginate @orgas
%tfoot
%tr
%th(colspan='12')= paginate @orgas

View File

@ -39,13 +39,15 @@
%td{ title: changes }= t ".#{version.event}_html"
%td= User.find version.whodunnit if version.whodunnit
%td= object
%td= l version.created_at
%td= l version.created_at, format: :short
%td
%a{ href: polymorphic_path(version.item_type.tableize.singularize,
id: version.item_id) }
%em.fa.fa-eye
= paginate @versions
%tfoot
%tr
%th(colspan='5')= paginate @versions
.formats
= link_to versions_path(format: :rss) do

View File

@ -4,6 +4,5 @@ fr:
first: '«'
last: '»'
previous: '‹'
next: '›'
next: Suivant
truncate: '...'