pagination
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -14,3 +14,3 @@ { | ||
}, | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"scripts": { | ||
@@ -17,0 +17,0 @@ "test": "vows --spec tests/*" |
@@ -14,2 +14,39 @@ ## pagination | ||
### Or customized renderer | ||
This example show how to generate markup for twitter boostrap, see example/twitter.html for template rendering | ||
var pagination = require('pagination') | ||
var boostrapPaginator = new pagination.TemplatePaginator({ | ||
prelink:'/', current: 3, rowsPerPage: 200, | ||
totalResult: 10020, slashSeparator: true, | ||
template: function(result) { | ||
var i, len, prelink; | ||
var html = '<div><ul class="pagination">'; | ||
if(result.pageCount < 2) { | ||
html += '</ul></div>'; | ||
return html; | ||
} | ||
prelink = this.preparePreLink(result.prelink); | ||
if(result.previous) { | ||
html += '<li><a href="' + prelink + result.previous + '">' + this.options.translator('PREVIOUS') + '</a></li>'; | ||
} | ||
if(result.range.length) { | ||
for( i = 0, len = result.range.length; i < len; i++) { | ||
if(result.range[i] === result.current) { | ||
html += '<li class="active"><a href="' + prelink + result.range[i] + '">' + result.range[i] + '</a></li>'; | ||
} else { | ||
html += '<li><a href="' + prelink + result.range[i] + '">' + result.range[i] + '</a></li>'; | ||
} | ||
} | ||
} | ||
if(result.next) { | ||
html += '<li><a href="' + prelink + result.next + '" class="paginator-next">' + this.options.translator('NEXT') + '</a></li>'; | ||
} | ||
html += '</ul></div>'; | ||
return html; | ||
} | ||
}); | ||
console.log(boostrapPaginator.render()); | ||
### OR | ||
@@ -32,17 +69,2 @@ | ||
### OR | ||
var pagination = require('pagination'); | ||
var paginator = new pagination.ItemPaginator({prelink:'/', slashSeparator: true, current: 3, rowsPerPage: 200, totalResult: 10020}); | ||
console.log(paginator.render()); | ||
// output (without newlines) | ||
<div class="paginator"> | ||
<span class="paginator-current-report">Results 401 - 600 of 10020</span> | ||
<a href="/page/1" class="paginator-first">First</a> | ||
<a href="/page/2" class="paginator-previous">Previous</a> | ||
<a href="/page/4" class="paginator-next">Next</a> | ||
<a href="/page/51" class="paginator-last">Last</a> | ||
</div> | ||
### OR need data from the calculation | ||
@@ -205,2 +227,2 @@ | ||
## Acknowledgements | ||
Template engine is taking mostly from https://github.com/vanng822/ejs which is a fork of https://github.com/visionmedia/ejs | ||
Template engine is taking mostly from https://github.com/vanng822/ejs which is a fork of https://github.com/visionmedia/ejs |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91203
39
1330
226