$.fn.extend({ JPager: function (cfg, pageIndex, pageSize) { if (cfg && pageIndex > 0 && pageSize>0) { var token = "#" this.attr("id"); this.empty(); var pageFirst = function () { $(token).JPager(cfg, 1, pageSize); };
var pagePre = function () { $(token).JPager(cfg, pageIndex - 1, pageSize); };
var pageLast = function () { $(token).JPager(cfg, parseInt($("#_tot").val()), pageSize); };
var pageNext = function () { $(token).JPager(cfg, pageIndex 1, pageSize); }; this).text()), pageSize); };
var pageGo = function () { var index = parseInt($("#_pos").val()); var total = parseInt($("#_tot").val()); if (index) { if (index > total) { ).JPager( cfg, total, pageSize); } else if (index < 1) { $(token).JPager(cfg, 1, pageSize); (token).JPager(cfg, index, pageSize); } } }; var checkGoNumber = function () { if (!Number(this.value)) { this.value = ""; } else { this.value = Number(this.value); } }; var initCustomer = function (recordCount) { if (cfg.customer) { if (cfg.customer.template) { var t =. vgl g.customer.template; t = t.replace(/%total%/gi, Math.ceil(recordCount / pageSize)).replace(/%current%/gi, pageIndex).replace(/%recordCount%/gi, recordCount).replace(/% pageSize%/gi, pageSize); if (cfg.customer.position == "right") { $("#_right").after(t); > sonst { $("#_left").before(t); } };
var changeState = function (total) { if (pageIndex == 1) { $("#_first").attr("class", "unable"); $("#_pre").attr("class", "unable" ) ").bind("click", pagePre).attr("class", "number"); } if (pageIndex == total) { $("#_last").attr ("class", "unable") ).bind("click", pageLast).attr("class", "number"); $("#_next").bind("click", pageNext).attr("class", "number "); } }; var initNumber = function (total, count, current) { if (total > 0 && count > 0). 🎜> aktuell = Gesamt; } var endIndex = gesamt; var startIndex = 1; { if (temp < ; count) { endIndex = count; startIndex = temp - count 1; endIndex = temp; }
if (total > count) { startIndex = total - count. 1; } $("#_number").empt(); für (var i = startIndex; i <= endIndex; i ) { var html = $("").text(i).bind("click", pageNumber); if (i == current) { $("#_number").append(html.attr("class", "selected")); else { $( "#_number").append(html.attr("class", "number")); ;
var initPager = function (data) { if ($.isArray(data.SearchResult) && data.RecordCount > 0) { $(token).append("< span id='_left'>首页上一页 span>< input id='_to' type='button' value='GO'/>下一页末页 "); var total = Math.ceil(data.RecordCount / pageSize); $("#_tot").val(total); $("#_pos").bind(" Blur", checkGoNumber); $("#_to").bind("click", pageGo);