$.fn.mypagination = function(total,cpage,psize,opts){
opts = $.extend({perPage:psize||1, recordCount:total||0, callback:function(){}}, opts||{});
opts.totalPage = Math.ceil(total/opts.perPage);
return this.each(function(){
var currPage;
if(cpage>opts.totalPage){
currPage=opts.totalPage;
}else{
currPage=cpage;
}
var panel = $(this);
function _gotopage(page){
return function(){
currPage = page;
render();
opts.callback(currPage);
};
}
function turnPage(){
var page = $(".turn-page-input",panel).val();
if(page===""+parseInt(page)){
page = parseInt(page);
if(page<=opts.totalPage&&page>=1){
currPage = page;
render();
opts.callback(currPage);
}else{
window.top.popupTips("请输入正确的页码");
}
}else{
window.top.popupTips("请输入正确的页码");
}
}
/* function render(){
var html = '
';
html = html + '';
html = html + '
共' + opts.recordCount + '条';
html = html + '每页' + opts.perPage + '条';
html = html + '';
html = html + '';
html = html + '';
html = html + '';
html = html + '';
html = html + '';
html = html + '当前 ' + currPage + '/' + opts.totalPage + ' 页 ';
html = html + '