summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-06-20 22:36:15 +0200
committeremkael <emkael@tlen.pl>2017-06-20 22:36:15 +0200
commite1de5d1538db6872727280771e2be0a8acc41843 (patch)
tree90982370105da5625b721be21fc69aa7af6b1bc2 /http
parentcd7bdbb74744e471990a34cb7ab201bc0cd2c19d (diff)
Custom pagination on ranking pagescustom-pagination
Fixes #8
Diffstat (limited to 'http')
-rw-r--r--http/res/ranking.js27
1 files changed, 25 insertions, 2 deletions
diff --git a/http/res/ranking.js b/http/res/ranking.js
index e36a992..f5b3d5e 100644
--- a/http/res/ranking.js
+++ b/http/res/ranking.js
@@ -82,6 +82,9 @@ var ranking = {
allParams.forEach(function(param) {
paramsChanged |= ranking.paramChanged(params, param);
});
+ if (ranking.paramChanged(params, 'pagesize')) {
+ $('table.data-table').removeAttr('data-paginate');
+ }
$('button.btn-primary').removeClass('btn-primary');
params.forEach(function(values, param) {
values.forEach(function(value) {
@@ -114,7 +117,11 @@ var ranking = {
}
$('table.data-table, .filters .panel-body').css('opacity', 1);
ranking.filtersDisabled = false;
- var pagesize = 40;
+ ranking.paginate(params);
+ },
+
+ paginate: function(params) {
+ var pagesize = params.get('pagesize') ? parseInt(params.get('pagesize')[0]) : parseInt($('select#pagesize').val());
var page = params.get('page') || [0];
var count = $('table.table-paginate').paginate(pagesize, parseInt(page[0]));
$('table.data-table tbody tr[data-paginate-visible=1]').eq(0).addClass('gold');
@@ -122,6 +129,7 @@ var ranking = {
$('table.data-table tbody tr[data-paginate-visible=1]').eq(2).addClass('bronze');
ranking.buildPaginator('#top-paginator', count, pagesize, page[0] || 1);
ranking.buildPaginator('#bottom-paginator', count, pagesize, page[0] || 1);
+ $(document).trigger('pagesizeChanged', { 'count': count, 'size': pagesize });
},
filtersDisabled: false,
@@ -136,7 +144,7 @@ var ranking = {
row.hide();
hidden = true;
}
- } else if (param != 'page') {
+ } else if (param.substr(0, 4) != 'page') {
if (value.indexOf(row.find('td.' + param).text().trim()) == -1) {
row.hide();
hidden = true;
@@ -266,7 +274,22 @@ var ranking = {
}, $(this));
});
+ $('select#pagesize').change(function() {
+ $('table.data-table').removeAttr('data-paginate');
+ handleParams(function(target, ev) {
+ var params = ranking.parseHash(location.hash);
+ params.delete('page');
+ params.set('pagesize', [parseInt(target.val())]);
+ return params;
+ }, $(this));
+ });
+
$(document).on('click', 'button.paginator-prev, button.paginator-next, button.paginator-page', ranking.changePage);
+
+ $(document).on('pagesizeChanged', function(ev, params) {
+ $('span#paginate-count').text(params.count);
+ $('select#pagesize').val(params.size);
+ });
}
};