diff --git a/app/assets/javascripts/pagination.coffee b/app/assets/javascripts/pagination.coffee new file mode 100644 index 00000000..61099343 --- /dev/null +++ b/app/assets/javascripts/pagination.coffee @@ -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() diff --git a/app/assets/stylesheets/all.sass b/app/assets/stylesheets/all.sass index 968fa3b2..851cf3ce 100644 --- a/app/assets/stylesheets/all.sass +++ b/app/assets/stylesheets/all.sass @@ -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 diff --git a/app/views/orgas/index.html.haml b/app/views/orgas/index.html.haml index cd8dc7a2..2d1519a4 100644 --- a/app/views/orgas/index.html.haml +++ b/app/views/orgas/index.html.haml @@ -59,4 +59,6 @@ = link_to edit_orga_path orga do %em.fa.fa-pencil -= paginate @orgas + %tfoot + %tr + %th(colspan='12')= paginate @orgas diff --git a/app/views/versions/index.haml b/app/views/versions/index.haml index 47620aa1..ba1f862a 100644 --- a/app/views/versions/index.haml +++ b/app/views/versions/index.haml @@ -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 diff --git a/config/locales/kaminari.fr.yml b/config/locales/kaminari.fr.yml index 84245996..bb06eb3c 100644 --- a/config/locales/kaminari.fr.yml +++ b/config/locales/kaminari.fr.yml @@ -4,6 +4,5 @@ fr: first: '«' last: '»' previous: '‹' - next: '›' + next: Suivant truncate: '...' -