Simple pagination algorithm
Requirements
- node.js
Install
$ npm install --save pagesify
Usage
var Pagesify = ; var pagesify = interval: 3 placeholder: '..' itemsPerPage: 3; var items = 'radiohead' 'jamie woon' 'actress' 'joy division' 'burial' 'sampha' 'the xx' 'nicolas jaar' 'boards of canada' 'james blake' 'nicolas jaar'; var currentPage = 3; var pagination = pagesify; console;// { handles: [ 'prev', 1, 2, 3, '..', 4, 'next' ] } console;/* pages: { '1': [ 'radiohead', 'jamie woon', 'actress' ], '2': [ 'joy division', 'burial', 'sampha' ], '3': [ 'the xx', 'nicolas jaar', 'boards of canada' ], '4': [ 'james blake', 'nicolas jaar' ], length: 4 } }*/
API
- createPageHandles
- convertListToPages
createPageHandles (pages, currentPage)
pages: object starting from 1
currentPage: number
Returns an array of handles
convertListToPages (list, itemsPerPage)
list: object starting from 1
itemsPerPage: number
Returns an object of pages
License
MIT © Ricardo Matias