|
/*---------------------------------------------------
* PagerControl for AJAX
* (c) 2005 Jigar Desai <desaijm@hotmail.com>
* Date Change: 12/31/2005
* requires: prototype.js http://prototype.conio.net/
*--------------------------------------------------*/
function PagerControl(pageSize,step){
this.PageSize = pageSize;
this.Step = step;
this.PageCount = 0;
this.CurrentPage = 1;
this.HeaderTemplate = "[ ";
this.ItemTemplate = "<a href=\"javascript:{#reloadfunction}({#page})\" >{#title}</a> ";
this.SelectedItemTemplate = "{#title} ";
this.FooterTemplate = " ]";
this.HostControlID = null;
}
PagerControl.prototype.RenderPager = function(reloadFunction){
var result = "";
if(this.PageCount > 1){
result += this.HeaderTemplate;
var startPoint = Math.floor((this.CurrentPage/this.Step)) * this.Step;
if((this.CurrentPage % this.Step) == 0) {
startPoint -= this.Step;
}
if(startPoint >= this.Step){
result += this.ItemTemplate.replace("{#page}",startPoint).replace("{#title}","...").replace("{#reloadfunction}",reloadFunction);
}
for(var i=startPoint +1;i<=this.PageCount && i<=(startPoint + this.Step);i++){
if(i != this.CurrentPage){
result += this.ItemTemplate.replace("{#page}",i).replace("{#title}",i).replace("{#reloadfunction}",reloadFunction);
}else{
result += this.SelectedItemTemplate.replace("{#title}",i);
}
}
if(startPoint < (this.PageCount - this.Step)){
result += this.ItemTemplate.replace("{#page}",(startPoint + this.Step +1)).replace("{#title}","...").replace("{#reloadfunction}",reloadFunction);
}
result += this.FooterTemplate;
}
$(this.HostControlID).innerHTML = result;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here