Skip to content

Commit

Permalink
Don't show pagesize for infinite scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
mlt committed Nov 28, 2019
1 parent 0a270b7 commit 8489c91
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions app/assets/javascripts/tabulatr/_tabulatr.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,27 @@ Tabulatr.prototype = {
var count_string = $('.tabulatr_count[data-table='+ tableId +']').data('format-string');
count_string = count_string.replace(/%\{current\}/, response.meta.count);
count_string = count_string.replace(/%\{total\}/, response.meta.total);
var ps = $('table#'+ tableId).data('pagesizes');
var pp;
if(ps){
select = $('<select class="form-control>');
$('table#'+ tableId).data('pagesizes').forEach(function(size){
label = size==9999 ? 'All' : size;
o = $('<option value="' + size + '" label="' + label + '">' + label + '</option>');
if(size==response.meta.pagesize){
o.attr('selected', true); // FIXME use prop // mlt
}
select.append(o);
});
pp = select.prop('outerHTML');
if(this.hasInfiniteScrolling){
count_string = count_string.substring(0, count_string.indexOf(' %{per_page}'));
} else {
pp = response.meta.pagesize;
var ps = $('table#'+ tableId).data('pagesizes');
var pp;
if(ps){
select = $('<select>');
$('table#'+ tableId).data('pagesizes').forEach(function(size){
label = size==9999 ? 'All' : size;
o = $('<option value="' + size + '" label="' + label + '">' + label + '</option>');
if(size==response.meta.pagesize){
o.attr('selected', true); // FIXME use prop // mlt
}
select.append(o);
});
pp = select.prop('outerHTML');
} else {
pp = response.meta.pagesize;
}
count_string = count_string.replace(/%\{per_page\}/, pp);
}
count_string = count_string.replace(/%\{per_page\}/, pp);
$('.tabulatr_count[data-table='+ tableId +']').html(count_string);
},

Expand Down

0 comments on commit 8489c91

Please sign in to comment.