12345 |
- function page_ctrl(e){function g(){b=/^\d+$/.test(b)?1>b?1:b>d?d:b:1;e.change_content(h,b);for(var a='<span class="page_total">\u5171 '+d+' \u9875</span><button class="iconfont icon-xiangzuo prev_page"></button>',c=0;c<d-1;c++)8<d&&6<b&&c<b-3?2>c?a+='<button class="page_num">'+(c+1)+"</button>":2==c&&(a+='<span class="page_dot">...</span>'):8<d&&b<d-3&&c>b+1?6<b&&c==b+2?a+='<span class="page_dot">...</span>':7>b&&(8>c?a+='<button class="page_num">'+(c+1)+"</button>":8==c&&(a+='<span class="page_dot">...</span>')):
- a=c==b-1?a+('<button class="page_num current_page">'+(c+1)+"</button>"):a+('<button class="page_num">'+(c+1)+"</button>");a=b==d?a+('<button class="page_num current_page">'+(c+1)+"</button>"):a+('<button class="page_num">'+(c+1)+"</button>");a+='<button class="iconfont icon-xiangyou next_page"></button><span class="page_total">\u5230\u7b2c</span><input class="input_page_num" type="text" ><span class="page_text">\u9875</span><button class="to_page_num">\u786e\u5b9a</button>';$(f).children(".page_ctrl").append(a);
- 1==b?$(f+" .page_ctrl .prev_page").attr("disabled","disabled").addClass("btn_dis"):$(f+" .page_ctrl .prev_page").removeAttr("disabled").removeClass("btn_dis");b==d?$(f+" .page_ctrl .next_page").attr("disabled","disabled").addClass("btn_dis"):$(f+" .page_ctrl .next_page").removeAttr("disabled").removeClass("btn_dis")}var f=void 0!==e.obj_box?e.obj_box:function(){},k=void 0!==e.total_item?parseInt(e.total_item):0,h=void 0!==e.per_num?parseInt(e.per_num):5,b=void 0!==e.current_page?parseInt(e.current_page):
- 1,d=Math.ceil(k/h);$(f).html('<div class="page_content"></div>');$(f).html('<div class="page_ctrl"></div>');g();$(f+" .page_ctrl").on("click","button",function(){var a=$(this);a.hasClass("prev_page")?1!=b&&(b--,a.parent(".page_ctrl").html(""),g()):a.hasClass("next_page")?b!=d&&(b++,a.parent(".page_ctrl").html(""),g()):a.hasClass("page_num")&&!a.hasClass("current_page")?(b=parseInt(a.html()),a.parent(".page_ctrl").html(""),g()):a.hasClass("to_page_num")&&(b=parseInt(a.siblings(".input_page_num").val()),
- a.parent(".page_ctrl").html(""),g())})};
|