/* * jQuery Pagination * Author: Austin Wulf (@austinwulf) * * Call the paginate method on an array * of elements. Accepts # of items per page * as an argument. Defaults to 5. * * Example: * $(selector).paginate(3); * * Released under the MIT License. * * v 1.0 */ (function($){ var paginate = { startPos: function(pageNumber, perPage) { // determine what array position to start from // based on current page and # per page return pageNumber * perPage; }, getPage: function(items, startPos, perPage) { // declare an empty array to hold our page items var page = []; // only get items after the starting position items = items.slice(startPos, items.length); // loop remaining items until max per page for (var i=0; i < perPage; i++) { page.push(items[i]); } return page; }, totalPages: function(items, perPage) { // determine total number of pages return Math.ceil(items.length / perPage); }, createBtns: function(totalPages, currentPage) { // create buttons to manipulate current page var pagination = $('