[%
var pages = [];
var addPage = function(text, page, i) {
if (arguments.length == 1)
{
page = text;
i = text;
}
var pageClass = text == "上一页" ? "prevPage" : (text == "下一页" ? "nextPage" : "");
pages.push({"text": text, "page": page, "className": pageClass});
if (arguments.length > 2 || arguments.length == 1)
pages.last = i;
};
if (this.count > 0)
{
var temp = [];
if (this.page <= 8)
temp = $A($R(1, this.page));
else
{
temp = $A($R(1, 3)); //前3页
temp = temp.concat($A($R(Math.max(this.currentPage - 2, 1), Math.min(this.currentPage + 2, this.page)))); //中间5页
temp = temp.concat($A($R(this.page - 2, this.page))); //后3页
}
this.simplePage ? void(0) : addPage("上一页", this.currentPage - 1, 0);
temp.each(function(el) {
var t;
if (el > 0)
{
t = el - pages.last;
if (t <= 0)
return;
if (t > 3)
addPage("...", -1);
else if (t > 1)
(t - 1).times(function(i) {addPage(el + i - t + 1);});
addPage(el);
}
});
this.simplePage ? void(0) : addPage("下一页", this.currentPage + 1);
}
%]
[%#+@link#%]
[%if (this.page != this.currentPage) {%]
[%=this.text%]
[% } else {%]
[%=this.text%]
[%}%]
[%#-@link#%]
[%#+@span#%]
[%=this.text%]
[%#-@span#%]
[%if (pages.length > (this.simplePage ? 1 : 3)) {%]
[%for(var i = 0; i < pages.length; i++)
{
if (pages[i].page > 0 && pages[i].page <= this.page) {%]
[%=this.link.GetView(pages[i], {currentPage: this.currentPage})%]
[% } else%]
[%=this.span.GetView(pages[i])%]
[%}%]
[%}%]
if (gotoPage.isDefault)
alert("Please define function [gotoPage]!");