/** * @version: v1.7 * @author: xgc-whj * @date: 2018-05-25 21:40:00 * @license: MIT license release * @jq22 address: http://www.jq22.com/jquery-info17548 * @GitHub: https://github.com/w0624/jquery-pagination * @description: jQuery分页插件,可自定义样式,默认有五套样式,可自定义插件选项,简单方便,兼容IE8 */ (function(){$.fn.extend({whjPaging:function(b,r){var g=$(this);if(b==="getPage"){return{totalSize:g.get(0).pageText.totalSize,currPage:g.get(0).pageText.staticCurrPage,pageSize:g.get(0).pageText.staticPageSize,totalPage:g.get(0).pageText.staticTotalPage}}else{if(b==="setPage"){g.get(0).pageText.currPage=r.currPage!=null?r.currPage:null;g.get(0).pageText.totalPage=r.totalPage!=null?r.totalPage:null;g.get(0).pageText.totalSize=r.totalSize!=null?r.totalSize:null;if(g.get(0).pageText.isShowPageSizeOpt){c()}}else{if(b!=null){var o=[{value:5,text:"5条/页",selected:true},{value:10,text:"10条/页"},{value:15,text:"15条/页"},{value:20,text:"20条/页"}];if(b.pageSizeOpt!=null){o=b.pageSizeOpt}var s=o[0].value;var x=o.length;for(var m=0;mg.get(0).pageText.totalPage){g.get(0).pageText.currPage=g.get(0).pageText.totalPage}}g.get(0).pageText.staticCurrPage=g.get(0).pageText.currPage;g.get(0).pageText.staticPageSize=g.get(0).pageText.pageSize;g.get(0).pageText.staticTotalPage=g.get(0).pageText.totalPage;var h=g.get(0).pageText.currPage<2?"whj_hoverDisable":"whj_hover";var e=g.get(0).pageText.currPage>=g.get(0).pageText.totalPage?"whj_hoverDisable":"whj_hover";var q=0;var f=0;var y=parseInt(g.get(0).pageText.showPageNum/2);if(g.get(0).pageText.showPageNum<2){f=g.get(0).pageText.currPage}else{if(g.get(0).pageText.totalPage<=g.get(0).pageText.showPageNum){f=1}else{if(g.get(0).pageText.currPage+y>g.get(0).pageText.totalPage){f=g.get(0).pageText.totalPage-g.get(0).pageText.showPageNum+1}else{if(g.get(0).pageText.currPage-y<1){f=1}else{f=g.get(0).pageText.currPage-y}}}}var t='
';if(g.get(0).pageText.isShowFL){t+='
'+g.get(0).pageText.firstPage+"
"}t+='
'+g.get(0).pageText.previousPage+"
";if(g.get(0).pageText.showPageNum>0){for(var n=f;n<=g.get(0).pageText.totalPage;n++){q++;var v=g.get(0).pageText.currPage==n?"whj_checked":"whj_hover";t+='
'+n+"
";if(q>=g.get(0).pageText.showPageNum){break}}}t+='
'+g.get(0).pageText.nextPage+"
";if(g.get(0).pageText.isShowFL){t+='
'+g.get(0).pageText.lastPage+"
"}if(g.get(0).pageText.isShowPageSizeOpt){t+='"}if(g.get(0).pageText.isShowSkip){t+='
'+g.get(0).pageText.skip+'
'+g.get(0).pageText.confirm+"
"}if(g.get(0).pageText.isShowRefresh){t+='
'+g.get(0).pageText.refresh+"
"}if(g.get(0).pageText.isShowTotalPage){var p=g.get(0).pageText.totalPageText.replace("{}",g.get(0).pageText.totalPage);t+='
'+p+"
"}if(g.get(0).pageText.isShowTotalSize){var a=g.get(0).pageText.isShowTotalPage?"whj_totalSizeSingle":"";var l=g.get(0).pageText.totalSizeText.replace("{}",g.get(0).pageText.totalSize);t+='
'+l+"
"}t+="
";g.html(t);if(g.get(0).pageText.isShowFL){if(h=="whj_hover"){g.find("div[name='whj_firstPage']").click(function(){if(g.get(0).pageText.isResetPage){g.get(0).pageText.pageSize=g.get(0).pageText.staticPageSize}g.get(0).pageText.currPage=1;u()})}if(e=="whj_hover"){g.find("div[name='whj_lastPage']").click(function(){if(g.get(0).pageText.isResetPage){g.get(0).pageText.pageSize=g.get(0).pageText.staticPageSize;g.get(0).pageText.currPage=g.get(0).pageText.staticTotalPage}else{g.get(0).pageText.currPage=g.get(0).pageText.totalPage}u()})}}if(h=="whj_hover"){g.find("div[name='whj_previousPage']").click(function(){if(g.get(0).pageText.isResetPage){g.get(0).pageText.pageSize=g.get(0).pageText.staticPageSize;g.get(0).pageText.currPage=g.get(0).pageText.staticCurrPage-1}else{g.get(0).pageText.currPage=g.get(0).pageText.currPage-1}u()})}if(e=="whj_hover"){g.find("div[name='whj_nextPage']").click(function(){if(g.get(0).pageText.isResetPage){g.get(0).pageText.pageSize=g.get(0).pageText.staticPageSize;g.get(0).pageText.currPage=g.get(0).pageText.staticCurrPage+1}else{g.get(0).pageText.currPage=g.get(0).pageText.currPage+1}u()})}if(g.find("div[name='whj_page']").length>0){g.find("div[name='whj_page']").click(function(){if(!$(this).hasClass("whj_checked")){if(g.get(0).pageText.isResetPage){g.get(0).pageText.pageSize=g.get(0).pageText.staticPageSize}g.get(0).pageText.currPage=+$(this).data("page");u()}})}if(g.get(0).pageText.isShowPageSizeOpt){g.find("select[name='whj_pageSize']").change(function(){var i=+$(this).val();if(g.get(0).pageText.isResetPage){$(this).find("option[value='"+g.get(0).pageText.staticPageSize+"']").prop("selected",true)}var k=parseInt(g.get(0).pageText.totalSize/i);if(k*i0){i=+i;if(i<1){i=1}else{if(i>g.get(0).pageText.totalPage){i=g.get(0).pageText.totalPage}}if(g.get(0).pageText.isResetPage){g.get(0).pageText.pageSize=g.get(0).pageText.staticPageSize}g.get(0).pageText.currPage=i;u()}})}if(g.get(0).pageText.isShowRefresh){g.find("div[name='whj_refresh']").click(function(){if(g.get(0).pageText.isResetPage){g.get(0).pageText.pageSize=g.get(0).pageText.staticPageSize;g.get(0).pageText.currPage=g.get(0).pageText.staticCurrPage}u()})}function u(){if(!g.get(0).pageText.isResetPage){g.whjPaging()}g.get(0).pageText.callBack(g.get(0).pageText.currPage,g.get(0).pageText.pageSize)}function c(){var k=[];var z=g.get(0).pageText.pageSizeOpt;for(var i in z){if(z[i].value==g.get(0).pageText.pageSize){k.push({value:z[i].value,text:z[i].text,selected:true})}else{k.push({value:z[i].value,text:z[i].text})}}g.get(0).pageText.pageSizeOpt=k}}})})();