var Pager=function(a,t,s){var p=this,e=$.extend({jump:!0,total:!0},s);t=t||function(a){alert(a)};var n=$(a);n.on("click","a.page",function(){return t($(this).attr("data-page")),!1}),n.on("click","button",function(){var a=parseInt($(this).prev().val());return a?(t(a),!1):($.tipError("请输入正确页码"),!1)}),this.total=0,this.render=function(a,t,s){p.total=a;var r=Math.ceil(a/t);s=s||1,s=parseInt(s);var u=function(a,t){for(var p=a;p<=t;p++)p==s?i.push('<span class="current">'+p+"</span>"):i.push('<a class="page" href="javascript:;" title="'+p+'" data-page="'+p+'">'+p+"</a>")},i=[];if(i.push('<div class="pages">'),e.total&&i.push("<span>共 "+a+" 条记录</span>"),r<4)r>1&&u(1,r);else{u(1,1);var l=s-2,c=s+2;l<2&&(l=2),c>r-1&&(c=r-1),l>2&&i.push('<span class="more">...</span>'),u(l,c),c<r-1&&i.push('<span class="more">...</span>'),u(r,r)}s>1&&i.push('<a class="page" href="javascript:;" title="'+(s-1)+'" data-page="'+(s-1)+'">上页</a>'),s<r&&i.push('<a class="page" href="javascript:;" title="'+(s+1)+'" data-page="'+(s+1)+'">下页</a>'),r>1&&e.jump&&i.push('<span class="jumpBox"><input type="text" value="'+s+'" class="page" /> <button>跳转</button></span>'),i.push("</div>"),n.html(i.join(""))}};module.exports=Pager;