From fe8cf5222fabf12c94d25505a8822c4c7c7ddfe0 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Thu, 18 Sep 2014 17:54:31 +0200 Subject: [PATCH] Added "..." when needed in paginator --- .../js/Presenters/PagedCollectionPresenter.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/public_html/js/Presenters/PagedCollectionPresenter.js b/public_html/js/Presenters/PagedCollectionPresenter.js index 3da01eca..fab1d837 100644 --- a/public_html/js/Presenters/PagedCollectionPresenter.js +++ b/public_html/js/Presenters/PagedCollectionPresenter.js @@ -13,6 +13,7 @@ App.Presenters.PagedCollectionPresenter = function( browsingSettings) { var $target; + var $pageList; var targetContent; var endlessScroll = browsingSettings.getSettings().endlessScroll; var scrollInterval; @@ -162,8 +163,14 @@ App.Presenters.PagedCollectionPresenter = function( function refreshPageList() { var pages = getVisiblePages(); - $target.find('.page-list').empty(); + $pageList.empty(); + var lastPage = 0; _.each(pages, function(page) { + if (page - lastPage > 1) { + $pageList.append(jQuery('
  • ')); + } + lastPage = page; + var $a = jQuery(''); $a.addClass('big-button'); $a.attr('href', getPageChangeLink(page)); @@ -173,14 +180,15 @@ App.Presenters.PagedCollectionPresenter = function( } var $li = jQuery('
  • '); $li.append($a); - $target.find('.page-list').append($li); + $pageList.append($li); }); } function render() { $target.html(template({originalHtml: targetContent})); + $pageList = $target.find('.page-list'); if (endlessScroll) { - $target.find('.page-list').remove(); + $pageList.remove(); } else { refreshPageList(); }