Yet another paginate view helper for nodejs.
Generate html twitter bootstrap pagination.
or json for another usage :
{
options: { showFirstLast: true, showPrevNext: true, showStep: true },
first: { cssclass: 'disable', href: '#', text: '««' },
previous: { cssclass: 'disable', href: '#', text: '«' },
step: [
{ ispageno: true, cssclass: 'active', href: '#', text: '1' },
{ ispageno: true, cssclass: '', href: '/unknowurl?pageno=2', text: '2' },
{ ispageno: true, cssclass: '', href: '/unknowurl?pageno=3', text: '3' },
{ ispageno: true, cssclass: '', href: '/unknowurl?pageno=4', text: '4' },
{ ispageno: true, cssclass: '', href: '/unknowurl?pageno=5', text: '5' },
{ ispageno: false, cssclass: 'disabled', href: '#', text: '…' },
{ ispageno: true, cssclass: '', href: '/unknowurl?pageno=99', text: '99' },
{ ispageno: true, cssclass: '', href: '/unknowurl?pageno=100', text: '100' }
],
next: { cssclass: '', href: '/unknowurl?pageno=2', text: '»' },
last: { cssclass: '', href: '/unknowurl?pageno=100', text: '»»' }
}
- Edit your
package.json
Add :
"dependencies": { "nodejs-yapaginate": "" },
- Execute
npm install
- Add
var paginate = require('nodejs-yapaginate');
in your code
Add :
<script src="/nodejs-yapaginate/lib/main.js"></script>
Html output :
console.log(paginate({totalItem:100, itemPerPage:10, currentPage:2, url:'/mybeautifulapp'}));
Json output :
console.log(paginate({totalItem:100, itemPerPage:10, currentPage:2, url:'/mybeautifulapp', getJson:true }));
name | default | description |
---|---|---|
totalItem | 1000 | total items |
itemPerPage | 10 | items per page |
currentPage | 1 | current selected page |
url | '/unknowurl' | default link |
params | {} | your personnal params add to link : if {aa:bb} => url?aa=bb |
parampageno | 'pageno' | key name add to link : url?pageno=10 |
showPrevNext | true | show previous and next button |
showFirstLast | true | show first and last button |
showStep | true | show step page. Show or Hide [1][2][3][4] |
hideDots | false | hide dots separator (if showStep = true) [1][2][...][99][100] |
DotsMidSize | 4 | show X step before and after current page (if hideDots = false) |
DotsEndSize | 2 | show X step after first and before end page (if hideDots = false) |
dotText | '…' | text for dots separator (if hideDots = false) |
firstText | '««' | text for goto first page |
prevText | '«' | text for goto previous page |
nextText | '»' | text for goto next page |
lastText | '»»' | text for goto last page |
addSep | '' | add \n in html output (only for debug) |
getJson |
|
get only Json ( not generate Html ) |
setJson |
|
|
Code licensed under the GNU GENERAL PUBLIC LICENSE Version 3