//min.js
!function(a,e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):a.amPagination=e(a.jQuery)}(this,function(a){var e=function(e,t){var i=a.extend({},a.fn.pagination.default,t);this.ele=e,this.container=function(e){if(e.checkTag(e.ele,"UL"))return e.ele;var t=e.ele.find("ul");if(t.length>0)return t.empty(),t;var i=a("<ul  />");return e.ele.append(i),i},this.onChangePage=function(a){return a&&"function"==typeof a&&this.ele.on("am.pagination.change",a),this},this.maxSize=i.maxSize||this.ele.data("maxSize"),this._page=-1,this.totals=i.totals,this.currPage=function(){return this._page+1},i.page&&i.page>0?this._page=i.page-1:this.ele.data("page")&&(this._page=parseInt(this.ele.data("page"))),this.pageSize=i.pageSize,this.selectPage=function(a,e){i.page=a,this.ele.trigger({type:"am.pagination.change",page:a,pageSize:this.pageSize,totals:this.totals,tiggerSource:e||"code"}),this._page=a-1,this.fill(),this.ele.trigger("am.context.change")},this.context=function(){return i},this.render=function(a){if(a.hasOwnProperty("totals")&&(this.totals=i.totals=a.totals,0===this.totals&&(this.totals=i.totals=1)),a.hasOwnProperty("pageSize")&&(this.pageSize=i.pageSize=a.pageSize),a.hasOwnProperty("page")){i.page=a.page;this._page=i.page-1}this.selectPage(this.currPage())},this.changeContext=function(){this.ele.attr("data-pagination",JSON.stringify(this.context()))},this.ele.on("am.context.change",a.proxy(this.changeContext,this)),this.click=function(e){e.preventDefault();var t="",i=a(e.target),s=i.parent("li");if(!s.hasClass("am-disabled")&&!s.hasClass("disabled"))if(s.hasClass("pager-first"))this.selectPage(1,"manual");else if(s.hasClass("pager-prev"))t=this.currPage()-1,this.selectPage(t,"manual");else if(s.hasClass("pager-next"))t=this.currPage()+1,this.selectPage(t,"manual");else if(s.hasClass("pager-last")){var n=Math.ceil(this.totals/this.pageSize);this.selectPage(n,"manual")}else{if(s.hasClass("am-active")||s.hasClass("active"))return;this.selectPage(parseInt(i.text()),"manual")}},this.fill=function(){if(this.pageSize<=0)throw Error("pageSize invalid!");if(this.totals<0)throw Error("totals invalid!");var a=this.container(this);0===this.totals?!0===i.hideIfEmpty&&(a.is(":hidden")||a.hide()):a.is(":hidden")&&a.show();var e=Math.ceil(this.totals/this.pageSize);this._page<0&&(this._page=0),this._page>e-1&&(this._page=e-1);var t=-1,s=-1;if(!0===i.rotate){if(this.maxSize%2!=0){var n=Math.floor(this.maxSize/2);this._page-n>=0?(t=this._page-n,s=this._page+n>e-1?e-1:this._page+n):(t=0,s=this.maxSize-1)}else{var l=this.maxSize/2;this._page-l>=0?(t=this._page-l,s=this._page+(l-1)<e?this._page+(l-1):e-1):(s=this.maxSize-1,t=0)}s+=1}else t=this._page-this._page%this.maxSize,s=t+this.maxSize;s=s>e?e:s,this.createUITmp({cpgidx:this._page,ctotals:this.totals,cboundaryLinks:i.boundaryLinks,cfirstText:i.firstText,cpageCount:e,clastText:i.lastText,cprevText:i.prevText,cnextText:i.nextText,cuiType:i.theme,cbtnSize:i.btnSize,cdirectionLinks:i.directionLinks,cspage:t,cepage:s},this.container(this))},this.container(this).on("click","li>a",a.proxy(this.click,this)),this.selectPage(i.page)};return e.Global={checkDom:function(a){return"object"==typeof HTMLElement?function(a){return a instanceof HTMLElement}:function(a){return a&&"object"==typeof a&&1===a.nodeType&&"string"==typeof a.nodeName}},check$:function(e){return!!e&&e instanceof a},addClassOnce:function(a,e){a.hasClass(e)||a.addClass(e)}},e.prototype={constructor:e,checkTag:function(t,i){return t instanceof a?t.get(0).tagName===i:e.Global.checkDom(t)?t.tagName===i:"string"==typeof t&&a(t).get(0).tagName===i},createUITmp:function(t,i){var s=[];if("amazeui"===t.cuiType){e.Global.addClassOnce(i,"am-pagination"),"sm"===t.cbtnSize?e.Global.addClassOnce(i,"am-pagination-sm"):"lg"===t.cbtnSize&&e.Global.addClassOnce(i,"am-pagination-lg"),!0===t.cboundaryLinks&&s.push('<li  class=" pager-first '+(0===t.cpgidx||t.ctotals<=0?"am-disabled":"")+'" ><a href="#">'+t.cfirstText+"</a></li>"),!0===t.cdirectionLinks&&s.push('<li  class=" pager-prev   '+(0===t.cpgidx||t.ctotals<=0?"am-disabled":"")+'  "><a href="#">'+t.cprevText+"</a></li>"),0!==t.cspage&&s.push("<li><span>...</span></li>");for(var n=t.cspage;n<t.cepage;n++)s.push("<li "+(t.cpgidx===n?'class="am-active"':"")+'><a href="#">'+(n+1)+"</a></li>");t.cepage!==t.cpageCount&&s.push("<li><span>...</span></li>"),!0===t.cdirectionLinks&&s.push(' <li class="pager-next '+(t.cpgidx===t.cpageCount-1||t.ctotals<=0?"am-disabled ":"")+'"><a href="#">'+t.cnextText+"</a></li>"),!0===t.cboundaryLinks&&s.push(' <li class=" pager-last '+(t.cpgidx===t.cpageCount-1||t.ctotals<=0?"am-disabled":"")+'"><a href="#">'+t.clastText+"</a></li>")}else if("bootstrap"===t.cuiType){e.Global.addClassOnce(i,"pagination"),"sm"===t.cbtnSize?e.Global.addClassOnce(i,"pagination-sm"):"lg"===t.cbtnSize&&e.Global.addClassOnce(i,"pagination-lg"),i.hasClass("pagination")||i.addClass("pagination"),!0===t.cboundaryLinks&&s.push('<li  class=" pager-first '+(0===t.cpgidx||t.ctotals<=0?"disabled":"")+'" ><a href="#">'+t.cfirstText+"</a></li>"),!0===t.cdirectionLinks&&s.push('<li  class=" pager-prev   '+(0===t.cpgidx||t.ctotals<=0?"disabled":"")+'  "><a href="#">'+t.cprevText+"</a></li>"),0!==t.cspage&&s.push("<li><span>...</span></li>");for(var n=t.cspage;n<t.cepage;n++)s.push("<li "+(t.cpgidx===n?'class="active"':"")+'><a href="#">'+(n+1)+"</a></li>");t.cepage!==t.cpageCount&&s.push("<li><span>...</span></li>"),!0===t.cdirectionLinks&&s.push(' <li class="pager-next '+(t.cpgidx===t.cpageCount-1||t.ctotals<=0?"disabled ":"")+'"><a href="#">'+t.cnextText+"</a></li>"),!0===t.cboundaryLinks&&s.push(' <li class=" pager-last '+(t.cpgidx===t.cpageCount-1||t.ctotals<=0?"disabled":"")+'"><a href="#">'+t.clastText+"</a></li>")}else{e.Global.addClassOnce(i,"am-pagination-default"),"sm"===t.cbtnSize?e.Global.addClassOnce(i,"am-pagination-default-sm"):"lg"===t.cbtnSize&&e.Global.addClassOnce(i,"am-pagination-default-lg"),!0===t.cboundaryLinks&&s.push('<li  class=" pager-first '+(0===t.cpgidx||t.ctotals<=0?"disabled":"")+'" ><a href="#">'+t.cfirstText+"</a></li>"),!0===t.cdirectionLinks&&s.push('<li  class=" pager-prev   '+(0===t.cpgidx||t.ctotals<=0?"disabled":"")+'  "><a href="#">'+t.cprevText+"</a></li>"),0!==t.cspage&&s.push("<li><span>...</span></li>");for(var n=t.cspage;n<t.cepage;n++)s.push("<li "+(t.cpgidx===n?'class="active"':"")+'><a href="#">'+(n+1)+"</a></li>");t.cepage!==t.cpageCount&&s.push("<li><span>...</span></li>"),!0===t.cdirectionLinks&&s.push(' <li class="pager-next '+(t.cpgidx===t.cpageCount-1||t.ctotals<=0?"disabled ":"")+'"><a href="#">'+t.cnextText+"</a></li>"),!0===t.cboundaryLinks&&s.push(' <li class=" pager-last '+(t.cpgidx===t.cpageCount-1||t.ctotals<=0?"disabled":"")+'"><a href="#">'+t.clastText+"</a></li>")}this.container(this).empty(),this.container(this).append(a(s.join("")))}},a.fn.pagination=function(t){var i={},s=arguments;if(this.attr("data-pagination")){var n=this.attr("data-pagination"),l=JSON.parse(n),c=function(){return 0!==s.length}()&&a.extend({},l,t);i=new e(this,!1===c?l:c)}else{i=new e(this,t);var p=JSON.stringify(i.context());this.attr("data-pagination",p)}return i},a.fn.pagination.default={maxSize:7,totals:100,page:1,pageSize:10,lastText:"&raquo;&raquo;",firstText:"&laquo;&laquo;",prevText:"&laquo;",nextText:"&raquo;",rotate:!0,directionLinks:!0,boundaryLinks:!0,theme:"",btnSize:"",hideIfEmpty:!1},function(t,i){var s={};return t instanceof a?s=t:e.Global.checkDom(t)?s=a(t):"string"==typeof t&&(s=a(t)),a.fn.pagination.call(s,i)}});