text: !function(e,i,t){var s=function(i,t){this.$elem=e(i),this.options=t,this.$container=null,this.$prevEllipsis=null,this.$nextEllipsis=null,this.currentPage=null,this.visiblePages=[],this.maxVisiblePages=5};s.prototype={defaults:{align:"center",lastPage:1,firstPage:1,urlParameter:"page",useUrlParameter:!0,onClickCallback:function(){}},init:function(){this.config=e.extend({},this.defaults,this.options);var i=this.config.useUrlParameter?this.parseUrl():this.config.firstPage;this.createPaginationBase(i)&&this.bindClickEvent()},createPaginationBase:function(i){if(isNaN(this.config.firstPage)||isNaN(this.config.lastPage))return console.error("Both firstPage and lastPage attributes need to be integer values"),!1;if(this.config.firstPage>this.config.lastPage)return console.error("Value of firstPage must be less than the value of lastPage"),!1;this.config.firstPage=parseInt(this.config.firstPage),this.config.lastPage=parseInt(this.config.lastPage),this.currentPage=this.config.firstPage-this.maxVisiblePages,this.$container=e("<ul>").addClass("pagination").addClass(this.config.align+"-align"),this.$prevEllipsis=this.util.Ellipsis(),this.$nextEllipsis=this.util.Ellipsis();var t=this.util.createPage(this.config.firstPage),s=this.util.createChevron("prev"),a=this.util.createChevron("next");if(this.$container.append(s).append(t).append(this.$prevEllipsis.$elem).append(this.$nextEllipsis.$elem).append(a),this.config.lastPage>this.config.firstPage){var n=this.util.createPage(this.config.lastPage);n.insertBefore(a)}return this.requestPage(i),this.renderActivePage(),this.$elem.append(this.$container),!0},requestPage:function(e){switch(e){case this.currentPage:return;case this.currentPage-1:this.requestPrevPage();break;case this.currentPage+1:this.requestNextPage();break;default:this.requestPageByNumber(e)}this.config.onClickCallback(this.currentPage),this.renderActivePage(),this.config.useUrlParameter&&this.updateUrlParam(this.config.urlParameter,this.currentPage)},requestPrevPage:function(){this.currentPage-=1,this.visiblePages.pop().remove(),this.visiblePages.unshift(this.insertPrevPaginationComponent(this.currentPage-1))},requestNextPage:function(){this.currentPage+=1,this.visiblePages.shift().remove(),this.visiblePages.push(this.insertNextPaginationComponent(this.currentPage+1))},requestPageByNumber:function(e){this.purgeVisiblePages(),this.currentPage=e,this.visiblePages.push(this.insertNextPaginationComponent(this.currentPage-1)),this.visiblePages.push(this.insertNextPaginationComponent(this.currentPage)),this.visiblePages.push(this.insertNextPaginationComponent(this.currentPage+1))},renderActivePage:function(){this.renderEllipsis(),this.$container.find("li.active").removeClass("active");var i=e(this.$container.find('[data-page="'+this.currentPage+'"]')[0]);i.addClass("active")},renderEllipsis:function(){this.$prevEllipsis.isHidden&&this.currentPage>=this.config.firstPage+this.maxVisiblePages?this.$prevEllipsis.show():!this.$prevEllipsis.isHidden&&this.currentPage<=this.config.firstPage+this.maxVisiblePages-1&&this.$prevEllipsis.hide(),this.$nextEllipsis.isHidden&&this.currentPage<=this.config.lastPage-this.maxVisiblePages?this.$nextEllipsis.show():!this.$nextEllipsis.isHidden&&this.currentPage>=this.config.lastPage-this.maxVisiblePages+1&&this.$nextEllipsis.hide()},bindClickEvent:function(){var i=this;this.$container.on("click","li",function(){var t=i.sanitizePageRequest(e(this).data("page"));i.requestPage(t),location.reload()})},insertPrevPaginationComponent:function(i){if(i>this.config.firstPage&&i<this.config.lastPage){var t=this.util.createPage(i);return t.insertAfter(this.$prevEllipsis.$elem)}return e("")},insertNextPaginationComponent:function(i){if(i>this.config.firstPage&&i<this.config.lastPage){var t=this.util.createPage(i);return t.insertBefore(this.$nextEllipsis.$elem)}return e("")},sanitizePageRequest:function(e){var i=this.config.firstPage;return"prev"===e?i=this.currentPage===this.config.firstPage?this.currentPage:this.currentPage-1:"next"===e?i=this.currentPage===this.config.lastPage?this.currentPage:this.currentPage+1:!isNaN(e)&&e>=this.config.firstPage&&e<=this.config.lastPage&&(i=parseInt(e)),i},purgeVisiblePages:function(){for(var e=this.visiblePages.length,i=0;e>i;i+=1)this.visiblePages.pop().remove()},parseUrl:function(){var e=this.getUrlParamByName(this.config.urlParameter)||this.config.firstPage;return this.sanitizePageRequest(e)},getUrlParamByName:function(e){e=e.replace(/[\[\]]/g,"\\$&");var t=i.location.href,s=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)"),a=s.exec(t);return a?a[2]?decodeURIComponent(a[2].replace(/\+/g," ")):"":null},updateUrlParam:function(e,s){var a=([location.protocol,"//",location.host,location.pathname].join(""),t.location.search),n=e+"="+s,r="?"+n;a&&(keyRegex=new RegExp("([?&])"+e+"[^&]*"),r=null!==a.match(keyRegex)?a.replace(keyRegex,"$1"+n):a+"&"+n),i.history.pushState("","",r)},util:{createPage:function(i){return e("<li>").html("<a href=javascript:;>"+i+"</a>").addClass("waves-effect").attr("data-page",i)},createChevron:function(i){var t="next"===i?"left":"right",s=e("<i>").addClass("waves-effect").addClass("material-icons").text("chevron_"+t);return this.createPage(i).text("").attr("data-page",i).append(s)},Ellipsis:function(){var i=e("<li>");return i.text("..."),i.addClass("hide disabled"),{$elem:i,isHidden:!0,show:function(){this.isHidden=!1,this.$elem.removeClass("hide")},hide:function(){this.isHidden=!0,this.$elem.addClass("hide")}}}}},s.defaults=s.prototype.defaults,e.fn.materializePagination=function(e){return this.each(function(){new s(this,e).init()})}}(jQuery,window,document);