!
function(t,s){
s={};
function pagesizeshow(startRow,endRow,counts){
var pagesizeshow="";
pagesizeshow+='<div class="row">'
pagesizeshow+='<div class="col-xs-6">'
pagesizeshow+='<div aria-live="polite" style="line-height: 75px;" role="status" id="datagrid_info" class="dataTables_info">'
pagesizeshow+='显示第'+startRow+'到第'+endRow+'条记录,共'+counts+'条记录'
pagesizeshow+='</div>'
pagesizeshow+='</div>'
return pagesizeshow;
}
/*
* counts 总页数
* linePages 每页多少条
* currentPage 当前页
*/
function page(s,$this){
var pagesNum="";
var currentPage=isnull(s.currentPage)==""?1:parseInt(s.currentPage);
if(isnull(s.pages)==""){
var counts=isnull(s.counts)!=""?parseInt(s.counts):0;
var linePages=isnull(s.linePages)==""?20:parseInt(s.linePages);
var showCounts=s.showCounts?true:false;
pagesNum=counts%linePages==0?counts/linePages:parseInt(counts/linePages)+1; //共多少页
//显示条数信息
var startRow=(parseInt(currentPage)-1)* parseInt(linePages)+1;
var endRow=currentPage*linePages>counts?counts:currentPage*linePages
}else{
pagesNum=parseInt(s.pages);
var showCounts=false;
}
var pageList='';
if(currentPage>pagesNum){
currentPage=pagesNum;
}
//获取上一页 下一页 值
//上一页
var prepage; //上一页
if(pagesNum>1){
if(currentPage==1){
prepage='<li class="previous disabled"><a href="javascript:void(0);" data-page="'+(currentPage-1)+'"><</a></li>';
}else{
prepage='<li class="paginate_button previous" aria-controls="datagrid" tabindex="0" id="datagrid_previous"><a href="javascript:void(0)" data-page="'+(currentPage-1)+'"><</a></li>';
}
}
//下一页
var nextpage;
if(pagesNum>1){
if(currentPage==pagesNum){
nextpage='<li class="paginate_button next disabled" aria-controls="datagrid" tabindex="0" id="datagrid_next"><a href="javascript:void(0)" data-page="'+(currentPage+1)+'">></a></li>';
}else{
nextpage='<li class="paginate_button next" aria-controls="datagrid" tabindex="0" id="datagrid_next"><a href="javascript:void(0)" data-page="'+(currentPage+1)+'">></a></li>';
}
}
//设置分页
if(pagesNum>1){
var shenyuh='<li class="paginate_button disabled" aria-controls="datagrid" tabindex="0" id="datagrid_ellipsis"><a href="javascript:void(0)">…</a></li>';
var firstpage='<li><a href="javascript:void(0)" data-page="1">1</a></li>';
var lastpage='<li><a href="javascript:void(0)" data-page="'+pagesNum+'">'+pagesNum+'</a></li>'; //末页
if(pagesNum<=11){
var yepage='';
for(var i=1; i<=pagesNum;i++){
if(i==currentPage){
yepage+='<li class="active"><a href="javascript:void(0)" data-page="'+i+'">'+i+'</a></li>';//"<span class='current'>"+i+"</span>"
}else{
yepage+='<li><a href="javascript:void(0)" data-page="'+i+'">'+i+'</a></li>';//"<a href='javascript:void(0)'>"+i+"</a>"
}
}//for结束
pageList+=prepage+yepage+nextpage;
} //pagesNum<=11结束
if(pagesNum>11){
if(currentPage<=6){
var yepage='';
for(var i=1; i<=9;i++){
if(i==currentPage){
yepage+='<li class="active"><a href="javascript:void(0)" data-page="'+i+'">'+i+'</a></li>'
}else{
yepage+='<li><a href="javascript:void(0)" data-page="'+i+'">'+i+'</a></li>';
}
}
pageList+=prepage+yepage+shenyuh+lastpage+nextpage;
}
if(currentPage>=pagesNum-6){
var yepage='';
for(var i=pagesNum-8; i<=pagesNum;i++){
if(i==currentPage){
yepage+='<li class="active"><a href="javascript:void(0)" data-page="'+i+'">'+i+'</a></li>';
}else{
yepage+='<li><a href="javascript:void(0)" data-page="'+i+'">'+i+'</a></li>';
}
}
pageList+=prepage+firstpage+shenyuh+yepage+nextpage;
}
if( currentPage>6 && currentPage<pagesNum-6){
$(".main_page").append(prepage+firstpage+shenyuh);
var yepage2='';
for(var i=currentPage-3; i<=currentPage-1;i++){
yepage2+='<li><a href="javascript:void(0)" data-page="'+i+'">'+i+'</a></li>'
}//for i结束
var currentpages='<li class="active"><a href="javascript:void(0)" data-page="'+currentPage+'">'+currentPage+'</a></li>'
var yepage1='';
for(var j=currentPage+1; j<=currentPage+3;j++){
yepage1+='<li><a href="javascript:void(0)" data-page="'+j+'">'+j+'</a></li>';
}//for i结束
pageList+=prepage+firstpage+shenyuh+yepage2+currentpages+yepage1+shenyuh+lastpage+nextpage;
}
} //pagesNum>13结束
} //pagesNum>1结束
//设置分页结束
/* page列表 */
var pageMain='';
pageMain+='<div class="col-xs-6 fr">';
pageMain+='<div id="page_num" class="dataTables_paginate paging_simple_numbers tr">';
pageMain+='<ul class="pagination">';
pageMain+=pageList;
pageMain+='</ul>';
pageMain+='</div>';
pageMain+='</div>';
showCounts && pagesNum>1?$this.html(pagesizeshow(startRow,endRow,counts)+pageMain):$this.html(pageMain)
//$this.html(pagesizeshow(startRow,endRow,counts)+pageMain)
}
/*去除""或undefind null*/
function isnull(str) {
if (str == null || str == undefined || str == "undefined") {
return "";
}
else {
return str;
}
}
t.fn.pages=function(s){
var $this=$(this);
page(s,$this);
}
/*
*isLoding :是否正在加载
*shadeClose:是否关闭遮罩层
*shade:遮罩层颜色透明度
*shadeColor: 遮罩层颜色
*loadType: 加载类型 有1、2、3三种
*/
t.isloading=function(s){
var isLoad=isnull(s.isLoad)==""?"false":s.isLoad;
var loadType=isnull(s.loadType)==""?3:s.loadType;
//var shadeClose=s.shadeClose?true:false;
var shade=isnull(s.shade)==""?0.1:s.shade;
var shadeColor=isnull(s.shadeColor)==""?"#333":s.shadeColor;
console.log("加载:"+loadType)
if (isLoad=="true") {
layer.load(loadType-1, {
shadeClose: false,
shade: [shade,shadeColor] //0.1透明度的白色背景
}); //0代表加载的风格,支持0-2
}
}
t.closeload=function(){
//console.log("close--"+y);
layer.closeAll('loading');
}
}(jQuery, window, document)
/* 点击分页 */
jQuery.fn.extend({
pageclick:function(s) {
var $this=$(this);
$this.delegate('.pagination li', 'click', function(){
if(!$(this).hasClass("disabled") &&!$(this).hasClass("active")){
var currentPages=parseInt($(this).find("a").attr("data-page"));
//$(this).addClass("active").siblings(".pagination li").removeClass("active");
s.callback(currentPages,$(this))
}
});
}
});