!function($){"use strict";var bootstrappaginator=function(element,options){this.init(element,options)},old=null;bootstrappaginator.prototype={init:function(element,options){this.$element=$(element);var version=options&&options.bootstrapmajorversion?options.bootstrapmajorversion:$.fn.bootstrappaginator.defaults.bootstrapmajorversion,id=this.$element.attr("id");if(2===version&&!this.$element.is("div"))throw"in bootstrap version 2 the pagination must be a div element. or if you are using bootstrap pagination 3. please specify it in bootstrapmajorversion in the option";if(version>2&&!this.$element.is("ul"))throw"in bootstrap version 3 the pagination root item must be an ul element.";this.currentpage=1,this.lastpage=1,this.setoptions(options),this.initialized=!0},setoptions:function(options){this.options=$.extend({},this.options||$.fn.bootstrappaginator.defaults,options),this.totalpages=parseint(this.options.totalpages,10),this.numberofpages=parseint(this.options.numberofpages,10),options&&"undefined"!=typeof options.currentpage&&this.setcurrentpage(options.currentpage),this.listen(),this.render(),this.initialized||this.lastpage===this.currentpage||this.$element.trigger("page-changed",[this.lastpage,this.currentpage])},listen:function(){this.$element.off("page-clicked"),this.$element.off("page-changed"),"function"==typeof this.options.onpageclicked&&this.$element.bind("page-clicked",this.options.onpageclicked),"function"==typeof this.options.onpagechanged&&this.$element.on("page-changed",this.options.onpagechanged),this.$element.bind("page-clicked",this.onpageclicked)},destroy:function(){this.$element.off("page-clicked"),this.$element.off("page-changed"),this.$element.removedata("bootstrappaginator"),this.$element.empty()},show:function(page){this.setcurrentpage(page),this.render(),this.lastpage!==this.currentpage&&this.$element.trigger("page-changed",[this.lastpage,this.currentpage])},shownext:function(){var pages=this.getpages();pages.next&&this.show(pages.next)},showprevious:function(){var pages=this.getpages();pages.prev&&this.show(pages.prev)},showfirst:function(){var pages=this.getpages();pages.first&&this.show(pages.first)},showlast:function(){var pages=this.getpages();pages.last&&this.show(pages.last)},onpageitemclicked:function(event){var type=event.data.type,page=event.data.page;this.$element.trigger("page-clicked",[event,type,page])},onpageclicked:function(event,originalevent,type,page){var currenttarget=$(event.currenttarget);switch(type){case"first":currenttarget.bootstrappaginator("showfirst");break;case"prev":currenttarget.bootstrappaginator("showprevious");break;case"next":currenttarget.bootstrappaginator("shownext");break;case"last":currenttarget.bootstrappaginator("showlast");break;case"page":currenttarget.bootstrappaginator("show",page)}},render:function(){var containerclass=this.getvaluefromoption(this.options.containerclass,this.$element),size=this.options.size||"normal",alignment=this.options.alignment||"left",pages=this.getpages(),listcontainer=2===this.options.bootstrapmajorversion?$("
"):this.$element,listcontainerclass=2===this.options.bootstrapmajorversion?this.getvaluefromoption(this.options.listcontainerclass,listcontainer):null,first=null,prev=null,next=null,last=null,p=null,i=0;switch(this.$element.prop("class",""),this.$element.addclass("pagination"),size.tolowercase()){case"large":case"small":case"mini":this.$element.addclass($.fn.bootstrappaginator.sizearray[this.options.bootstrapmajorversion][size.tolowercase()])}if(2===this.options.bootstrapmajorversion)switch(alignment.tolowercase()){case"center":this.$element.addclass("pagination-centered");break;case"right":this.$element.addclass("pagination-right")}for(this.$element.addclass(containerclass),this.$element.empty(),2===this.options.bootstrapmajorversion&&(this.$element.append(listcontainer),listcontainer.addclass(listcontainerclass)),this.pageref=[],pages.first&&(first=this.buildpageitem("first",pages.first),first&&listcontainer.append(first)),pages.prev&&(prev=this.buildpageitem("prev",pages.prev),prev&&listcontainer.append(prev)),i=0;i"),itemcontent=$(""),text="",title="",itemcontainerclass=this.options.itemcontainerclass(type,page,this.currentpage),itemcontentclass=this.getvaluefromoption(this.options.itemcontentclass,type,page,this.currentpage),tooltipopts=null;switch(type){case"first":if(!this.getvaluefromoption(this.options.shouldshowpage,type,page,this.currentpage))return;text=this.options.itemtexts(type,page,this.currentpage),title=this.options.tooltiptitles(type,page,this.currentpage);break;case"last":if(!this.getvaluefromoption(this.options.shouldshowpage,type,page,this.currentpage))return;text=this.options.itemtexts(type,page,this.currentpage),title=this.options.tooltiptitles(type,page,this.currentpage);break;case"prev":if(!this.getvaluefromoption(this.options.shouldshowpage,type,page,this.currentpage))return;text=this.options.itemtexts(type,page,this.currentpage),title=this.options.tooltiptitles(type,page,this.currentpage);break;case"next":if(!this.getvaluefromoption(this.options.shouldshowpage,type,page,this.currentpage))return;text=this.options.itemtexts(type,page,this.currentpage),title=this.options.tooltiptitles(type,page,this.currentpage);break;case"page":if(!this.getvaluefromoption(this.options.shouldshowpage,type,page,this.currentpage))return;text=this.options.itemtexts(type,page,this.currentpage),title=this.options.tooltiptitles(type,page,this.currentpage)}return itemcontainer.addclass(itemcontainerclass).append(itemcontent),itemcontent.addclass(itemcontentclass).html(text).on("click",null,{type:type,page:page},$.proxy(this.onpageitemclicked,this)),this.options.pageurl&&itemcontent.attr("href",this.getvaluefromoption(this.options.pageurl,type,page,this.currentpage)),this.options.usebootstraptooltip?(tooltipopts=$.extend({},this.options.bootstraptooltipoptions,{title:title}),itemcontent.tooltip(tooltipopts)):itemcontent.attr("title",title),itemcontainer},setcurrentpage:function(page){if(page>this.totalpages||1>page)throw"page out of range";this.lastpage=this.currentpage,this.currentpage=parseint(page,10)},getpages:function(){var totalpages=this.totalpages,pagestart=0===this.currentpage%this.numberofpages?(parseint(this.currentpage/this.numberofpages,10)-1)*this.numberofpages+1:parseint(this.currentpage/this.numberofpages,10)*this.numberofpages+1,output=[],i=0,counter=0;for(pagestart=1>pagestart?1:pagestart,i=pagestart,counter=0;counter=i;i+=1,counter+=1)output.push(i);return output.first=1,output.prev=this.currentpage>1?this.currentpage-1:1,output.next=this.currentpage