Skip to content

A utility for generating pagings with first/last page and ellipsis.

License

Notifications You must be signed in to change notification settings

justlep/paginghelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

paginghelper Build Status Bower version

A utility for generating an object describing a paging, including an ellipse value between the "middle block" of displayed pages and the first and/or last page.

Demo (based on KnockoutJS): http://codepen.io/justlep/pen/YWbWxq

Example (using explicit currentPage and lastPage):

expect(PagingHelper.getPagingInfo({
    currentPage: 5,
    lastPage: 9,
    displayedPages: 5,
    ellipseValue: '---',
})).toEqual({
    ellipseValue: '---',
    currentPage: 5,
    lastPage: 9,
    previousPage: 4,
    nextPage: 6,
    hasPreviousPage: true,
    hasNextPage: true,
    pageNumbers: [0, '---', 3, 4, 5, 6, 7, '---', 9]
});

Example (using firstItemOffset, itemsPerPage and totalItems):

expect(PagingHelper.getPagingInfo({
    totalItems: 99,
    itemsPerPage: 10,
    firstItemOffset: 90,
    displayedPages: 5,
    ellipseValue: '----'
})).toEqual({
    ellipseValue: '----',
    currentPage: 9,
    lastPage: 9,
    previousPage: 8,
    nextPage: 10,
    hasPreviousPage: true,
    hasNextPage: false,
    pageNumbers: [0, '----', 5, 6, 7, 8, 9]
});

See PagingHelper.js or PagingHelper.spec.js.

Installation via Bower

$ bower install --save paginghelper

About

A utility for generating pagings with first/last page and ellipsis.

Resources

License

Stars

Watchers

Forks

Packages

No packages published