Skip to content

Commit

Permalink
fix: cap the number of page displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelastic committed Sep 3, 2015
1 parent 3cc80f5 commit bc6c2e2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions widgets/pagination/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ var React = require('react');

var utils = require('../../lib/widgetUtils.js');

function hits({container, cssClass, labels, maxPages} = {}) {
function pagination({container, cssClass, labels, maxPages} = {}) {
var Pagination = require('../../components/Pagination/');
var containerNode = utils.getContainerNode(container);

return {
render: function(results, state, helper) {
var nbPages = maxPages !== undefined ? maxPages : results.nbPages;
var nbPages = results.nbPages;
if (maxPages !== undefined) {
nbPages = Math.min(maxPages, results.nbPages);
}

React.render(
<Pagination
Expand All @@ -25,4 +28,4 @@ function hits({container, cssClass, labels, maxPages} = {}) {
};
}

module.exports = hits;
module.exports = pagination;

0 comments on commit bc6c2e2

Please sign in to comment.