Added "..." when needed in paginator
This commit is contained in:
parent
6defeb0da4
commit
fe8cf5222f
1 changed files with 11 additions and 3 deletions
|
@ -13,6 +13,7 @@ App.Presenters.PagedCollectionPresenter = function(
|
||||||
browsingSettings) {
|
browsingSettings) {
|
||||||
|
|
||||||
var $target;
|
var $target;
|
||||||
|
var $pageList;
|
||||||
var targetContent;
|
var targetContent;
|
||||||
var endlessScroll = browsingSettings.getSettings().endlessScroll;
|
var endlessScroll = browsingSettings.getSettings().endlessScroll;
|
||||||
var scrollInterval;
|
var scrollInterval;
|
||||||
|
@ -162,8 +163,14 @@ App.Presenters.PagedCollectionPresenter = function(
|
||||||
|
|
||||||
function refreshPageList() {
|
function refreshPageList() {
|
||||||
var pages = getVisiblePages();
|
var pages = getVisiblePages();
|
||||||
$target.find('.page-list').empty();
|
$pageList.empty();
|
||||||
|
var lastPage = 0;
|
||||||
_.each(pages, function(page) {
|
_.each(pages, function(page) {
|
||||||
|
if (page - lastPage > 1) {
|
||||||
|
$pageList.append(jQuery('<li><a>…</a></li>'));
|
||||||
|
}
|
||||||
|
lastPage = page;
|
||||||
|
|
||||||
var $a = jQuery('<a/>');
|
var $a = jQuery('<a/>');
|
||||||
$a.addClass('big-button');
|
$a.addClass('big-button');
|
||||||
$a.attr('href', getPageChangeLink(page));
|
$a.attr('href', getPageChangeLink(page));
|
||||||
|
@ -173,14 +180,15 @@ App.Presenters.PagedCollectionPresenter = function(
|
||||||
}
|
}
|
||||||
var $li = jQuery('<li/>');
|
var $li = jQuery('<li/>');
|
||||||
$li.append($a);
|
$li.append($a);
|
||||||
$target.find('.page-list').append($li);
|
$pageList.append($li);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
$target.html(template({originalHtml: targetContent}));
|
$target.html(template({originalHtml: targetContent}));
|
||||||
|
$pageList = $target.find('.page-list');
|
||||||
if (endlessScroll) {
|
if (endlessScroll) {
|
||||||
$target.find('.page-list').remove();
|
$pageList.remove();
|
||||||
} else {
|
} else {
|
||||||
refreshPageList();
|
refreshPageList();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue