Skip to content

Commit

Permalink
Pagination: fix issues in footer when no results found; fixes #173
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth G. Franqueiro committed May 24, 2012
1 parent 664d0ba commit 77f9fde
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions extensions/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,22 @@ function(_StoreMixin, declare, lang, Deferred, on, query, string, has, put, i18n
}
}

// Remove the old handler if it has been created.
if(pagingTextBoxHandle){ pagingTextBoxHandle.remove(); }
linksNode.innerHTML = "";
query(".dgrid-first, .dgrid-previous", paginationNavigationNode).forEach(function(link){
put(link, (currentPage == 1 ? "." : "!") + "dgrid-page-disabled");
});
query(".dgrid-last, .dgrid-next", paginationNavigationNode).forEach(function(link){
put(link, (currentPage == end ? "." : "!") + "dgrid-page-disabled");
put(link, (currentPage >= end ? "." : "!") + "dgrid-page-disabled");
});

if(pagingLinks){
if(pagingLinks && end > 0){
// always include the first page (back to the beginning)
pageLink(1);
var start = currentPage - pagingLinks;
if(start > 2) {
// visual indication of skipped page links
put(linksNode, 'span.dgrid-page-skip', '...');
put(linksNode, "span.dgrid-page-skip", "...");
}else{
start = 2;
}
Expand All @@ -176,12 +175,12 @@ function(_StoreMixin, declare, lang, Deferred, on, query, string, has, put, i18n
pageLink(i);
}
if(currentPage + pagingLinks + 1 < end){
put(linksNode, 'span.dgrid-page-skip', '...');
put(linksNode, "span.dgrid-page-skip", "...");
}
// last link
pageLink(end);
}else if(grid.pagingTextBox){
// the pageLink will create our textbox for us
// The pageLink function is also used to create the paging textbox.
pageLink(currentPage);
}
},
Expand Down Expand Up @@ -237,7 +236,7 @@ function(_StoreMixin, declare, lang, Deferred, on, query, string, has, put, i18n
Deferred.when(results.total, function(total){
// update status text based on now-current page and total
grid.paginationStatusNode.innerHTML = string.substitute(i18n.status, {
start: start + 1,
start: Math.min(start + 1, total),
end: Math.min(total, start + count),
total: total
});
Expand Down

0 comments on commit 77f9fde

Please sign in to comment.