var Pager=function(a,t,s){var p=this,e=$.extend({jump:!0,total:!0},s);t=t||function(a){alert(a)};var r=$(a);r.on("click","a.page",function(){var a=$(this).attr("data-page");return t(a),!1}),r.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 n=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>"),n<4)n>1&&u(1,n);else{u(1,1);var l=s-2,c=s+2;l<2&&(l=2),c>n-1&&(c=n-1),l>2&&i.push('<span class="more">...</span>'),u(l,c),c<n-1&&i.push('<span class="more">...</span>'),u(n,n)}s>1&&i.push('<a class="page" href="javascript:;" title="'+(s-1)+'" data-page="'+(s-1)+'">上页</a>'),s<n&&i.push('<a class="page" href="javascript:;" title="'+(s+1)+'" data-page="'+(s+1)+'">下页</a>'),n>1&&e.jump&&i.push('<span class="jumpBox"><input type="text" value="'+s+'" class="page" /> <button>跳转</button></span>'),i.push("</div>"),r.html(i.join(""))}};module.exports=Pager;