/* materialize Pagination v0.2.2 http://mirjamsk.github.io/materialize-pagination/ Sample usage: $('#pagination').materializePagination({ align: 'left', lastPage: 10, firstPage: 1, urlParameter: 'page', useUrlParameter: true, onClickCallback: function(requestedPage){ console.log('Requested page is '+ requestedPage) } }); */ ;(function($, window, document, undefined) { var MaterializePagination = function(elem, options) { this.$elem = $(elem); this.options = options; this.$container = null; this.$prevEllipsis = null; this.$nextEllipsis = null; this.currentPage = null; this.visiblePages = []; this.maxVisiblePages = 3; }; MaterializePagination.prototype = { defaults: { align: 'center', lastPage: 1, firstPage: 1, urlParameter: 'page', useUrlParameter: true, onClickCallback: function(){} }, init: function() { // Combine defaults with user-specified options this.config = $.extend({}, this.defaults, this.options); // Get page defined by the urlParameter var requestedPage = this.config.useUrlParameter ? this.parseUrl() : this.config.firstPage; // Create initial pagination and add it to the DOM if(this.createPaginationBase(requestedPage)) this.bindClickEvent(); }, createPaginationBase: function(requestedPage) { //alert('getting called'); if (isNaN(this.config.firstPage) || isNaN(this.config.lastPage) ){ console.error('Both firstPage and lastPage attributes need to be integer values'); return false; } else if (this.config.firstPage > this.config.lastPage ){ console.error('Value of firstPage must be less than the value of lastPage'); return false; } this.config.firstPage = parseInt(this.config.firstPage); this.config.lastPage = parseInt(this.config.lastPage); this.currentPage = this.config.firstPage - this.maxVisiblePages; this.$container = $('