window.F4A=window.F4A||{};F4A.widget=F4A.widget||{};F4A.widget.Pager=F4A.widget.Pager||function(container,config){var _=this;var _id=F4A.widget.Pager.count++;var Const={PG_STATUS_READY:0,PG_STATUS_GO:1,PG_DEF_OFFSETSIZE:2,PG_DEF_PAGESIZE:10} var TEMPLATE={CONTENT:'
',FIRST_DISABLE:'首页',FIRST_ENABLE:'1',LAST_DISABLE:'末页',LAST_ENABLE:'{pagenum}',PREVIOUS_DISABLE:'上一页',PREVIOUS_ENABLE:'上一页',NEXT_DISABLE:'下一页',NEXT_ENABLE:'下一页',PAGE_NORMAL:'{pagenum}',PAGE_CURRENT:'{pagenum}',PAGE_SIMPLE:'{pagenum}',GO_PAGE_INPUT:'',GO_PAGE_BUTTON:'',ELLIPSIS:'…',CLASS_NAME:'mod_pagenav'} this.eleContainer=null;this.totalNum=0;this.type=0;this.totalPage=0;this.pageSize=Const.PG_DEF_PAGESIZE;this.previousPage=0;this.currentPage=0;this.offsetPage=Const.PG_DEF_OFFSETSIZE;this.staus=Const.PG_STATUS_READY;this.initialized=false;this.onTurn=function(page,pagesize){};this.hideEmpty=true;this.init=function(){var i;if(!container)return;this.eleContainer=container;if(typeof config=="object"){for(i in config){if(typeof this[i]!=undefined){this[i]=config[i];}} if(config.type!=undefined){this.setType(config.type);} if(typeof config.template=="object"){for(i in config.template){this.setTemplate(i,config.template[i]);}} if(!!config.totalNum){this.setTotalNum(config.totalNum);} if(!!config.totalPage){} if(!!this.totalPage){this.fillPager();}else{this.eleContainer.style.display='none';}} this.initialized=true;} this.setTemplate=function(tName,strTmpl){if(TEMPLATE[tName.toUpperCase()]==undefined){return;} TEMPLATE[tName.toUpperCase()]=strTmpl;} this.setType=function(aType){if(aType==1){this.setTemplate("CLASS_NAME","mod_pagenav_style2");this.setTemplate("PREVIOUS_DISABLE",'< 上一页');this.setTemplate("PREVIOUS_ENABLE",'< 上一页');this.setTemplate("NEXT_DISABLE",'下一页 >');this.setTemplate("NEXT_ENABLE",'下一页 >');this.setTemplate("PAGE_NORMAL",'{pagenum}');this.setTemplate("PAGE_CURRENT",'{pagenum}');this.setTemplate("FIRST_DISABLE",'首页');this.setTemplate("FIRST_ENABLE",'1');this.setTemplate("LAST_DISABLE",'末页');this.setTemplate("LAST_ENABLE",'{pagenum}');}} this.setTotalNum=function(total,blnRefresh){var orgPage=this.totalPage;var orgCurPage=this.currentPage;this.totalNum=total;this.totalPage=Math.ceil(total/this.pageSize);this.currentPage=Math.min(this.totalPage,this.currentPage);if(!!blnRefresh){if(orgPage!=this.totalPage){this.fillPager();} this.refresh();}} this.fillPager=function(){if(!this.currentPage)return;var pageArr=[];var pageHTML='';var start,end,i;var aBtn;start=(this.currentPage-this.offsetPage>0)?(this.currentPage-this.offsetPage):1;end=(this.currentPage+this.offsetPage<=this.totalPage)?(this.currentPage+this.offsetPage):this.totalPage;var pagerContent;if(this.type==2){pagerContent=TEMPLATE.PAGE_SIMPLE.replace(/\{pagenum\}/g,this.currentPage+"/"+this.totalPage);}else{for(i=start;i<=end;i++){if(i==this.currentPage){pageArr.push(TEMPLATE.PAGE_CURRENT.replace(/\{pagenum\}/g,i));}else{pageArr.push(TEMPLATE.PAGE_NORMAL.replace(/\{pagenum\}/g,i));}} pagerContent=pageArr.join('');} pageHTML=TEMPLATE.CONTENT.replace(/\{pager\}/g,pagerContent).replace(/\{first\}/g,(this.currentPage-this.offsetPage<=1)?"":(TEMPLATE.FIRST_ENABLE+((this.currentPage-this.offsetPage>2)?TEMPLATE.ELLIPSIS:""))).replace(/\{previous\}/g,(this.currentPage==1)?TEMPLATE.PREVIOUS_DISABLE:TEMPLATE.PREVIOUS_ENABLE).replace(/\{next\}/g,(this.currentPage==this.totalPage)?TEMPLATE.NEXT_DISABLE:TEMPLATE.NEXT_ENABLE).replace(/\{last\}/g,(this.currentPage+this.offsetPage>this.totalPage-1)?"":((this.currentPage+this.offsetPage