pagination
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -1,3 +0,29 @@ | ||
var util = require('util'); | ||
var util; | ||
/* Check if clientside or serverside */ | ||
if( typeof module == "undefined" && typeof window == "object") { | ||
window.pagination = {}; | ||
module = { | ||
exports : window.pagination | ||
}; | ||
util = { | ||
inherits : function(subc, superc) { | ||
if(!superc || !subc) { | ||
throw new Error("extend failed, please check that all dependencies are included."); | ||
} | ||
var F = function() { | ||
}; | ||
F.prototype = superc.prototype; | ||
subc.prototype = new F(); | ||
subc.prototype.constructor = subc; | ||
subc.superclass = superc.prototype; | ||
if(superc.prototype.constructor == Object.prototype.constructor) { | ||
superc.prototype.constructor = superc; | ||
} | ||
} | ||
}; | ||
} else { | ||
util = require('util'); | ||
} | ||
var translations = { | ||
@@ -196,3 +222,3 @@ 'NEXT' : 'Next', | ||
this.set('pageLinks', 1); | ||
}; | ||
@@ -204,10 +230,7 @@ module.exports.ItemPaginator = ItemPaginator; | ||
ItemPaginator.prototype.renderCurrentPageReport = function(fromResult, toResult, totalResult) { | ||
if (!this.options.translationCache) { | ||
if(!this.options.translationCache) { | ||
return this.options.translator('CURRENT_PAGE_REPORT').replace('{FromResult}', fromResult).replace('{ToResult}', toResult).replace('{TotalResult}', totalResult); | ||
} | ||
if (!translationCache.CURRENT_PAGE_REPORT) { | ||
var template = "return '" + (this.options.translator('CURRENT_PAGE_REPORT').replace("'", "\'") | ||
.replace('{FromResult}', "' + fromResult + '") | ||
.replace('{ToResult}', "' + toResult + '") | ||
.replace('{TotalResult}', "' + totalResult + '")) + "';"; | ||
if(!translationCache.CURRENT_PAGE_REPORT) { | ||
var template = "return '" + (this.options.translator('CURRENT_PAGE_REPORT').replace("'", "\'").replace('{FromResult}', "' + fromResult + '").replace('{ToResult}', "' + toResult + '").replace('{TotalResult}', "' + totalResult + '")) + "';"; | ||
translationCache.CURRENT_PAGE_REPORT = new Function('fromResult, toResult, totalResult', template); | ||
@@ -226,3 +249,3 @@ } | ||
html += '</span>'; | ||
if(result.first) { | ||
@@ -251,3 +274,2 @@ html += '<a href="' + prelink + 'page=' + result.first + '" class="paginator-first">' + this.options.translator('FIRST') + '</a>'; | ||
} | ||
html += '</div>'; | ||
@@ -254,0 +276,0 @@ return html; |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"version": "0.2.1" | ||
"version": "0.3.0" | ||
} |
@@ -50,3 +50,22 @@ ## pagination | ||
pageCount: 51 } | ||
## Pagination on client side | ||
<html> | ||
<head> | ||
<script src="../lib/pagination.js"></script> | ||
</head> | ||
<body> | ||
<div id="paging"></div> | ||
<script type="text/javascript"> | ||
(function() { | ||
var paginator = new pagination.ItemPaginator({prelink:'/', current: 3, rowsPerPage: 200, totalResult: 10020}); | ||
var html = paginator.render(); | ||
var paginator = pagination.create('search', {prelink:'/', current: 1, rowsPerPage: 200, totalResult: 10020}); | ||
html += paginator.render(); | ||
document.getElementById("paging").innerHTML = html; | ||
})(); | ||
</script> | ||
</body> | ||
</html> | ||
## Options | ||
@@ -53,0 +72,0 @@ Object to pass to paginator classes (second argument when using create function) |
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
23876
13
637
111