jQuery Pagination Plugin

I found a jQuery pagination plugin at http://rohitsengar.cueblocks.net/jquery-pagination-plugin/. The plugin is brilliant except for it’s lack of jQuery.noConflict() solution. I have unminified the plugin and made the small changes necessary for jQuery.noConflict() support. I hope the author (Rohit) don’t mind me unminifying his script and redistributing it here. If you have any isues please feel free to leave your comment, or go over to the original website to get Rohit’s help.

jQuery.fn.extend({
        pagination: function () {
                paginatorId = this;
                switch (paginatorPosition) {
                case 'top':
                        {
                                paginatorId.before('
'); break } case 'bottom': { paginatorId.after('
'); break } case 'both': { paginatorId.before('
'); paginatorId.after('
'); break } default: { paginatorId.after('
') } } initPaginator() }, depagination: function () { $('.paginator').remove(); paginatorId.children().show() } }); function initPaginator() { if (itemsPerPage < 1) itemsPerPage = 5; allItems = paginatorId.children().length; if (allItems % itemsPerPage == 0) lastPage = parseInt(allItems / itemsPerPage); else lastPage = parseInt(allItems / itemsPerPage) + 1; if ((startPage < 1) || (startPage > lastPage)) startPage = 1; if (!showIfSinglePage) { if (lastPage > 1) appendContent(startPage, 1) } else appendContent(startPage, 1) } function appendContent(a, b) { if (a < 0) { if (a == -1) a = currentPage - 1; else a = currentPage + 1 } currentPage = a; till = (currentPage - 1) * itemsPerPage; if (!b) { paginatorId.fadeOut("medium", function () { createPaginator(); paginatorId.children().hide(); paginatorId.children().slice(till, itemsPerPage + till).show(); paginatorId.fadeIn("medium") }) } else { createPaginator(); paginatorId.children().hide(); paginatorId.children().slice(till, itemsPerPage + till).show() } } function createPaginator() { jQuery(".paginator").html(""); var a = ''; var b = ''; var c = ''; var d = ''; var e = ' Page ' + currentPage + ' of ' + lastPage + ' Page(s) '; var f = ' ' + textGoToPage + ' '; for (var i = 0; i < paginatorValues.length; i++) { if (itemsPerPage == paginatorValues[i]) g += ''; else g += '' } g += ''; if (currentPage == 1) { style = '' + firstPageSymbol + '' + separator; a = b = style; style = '' + previousPageSymbol + '' + separator; a += style; b += style; c += style; d += style } else { style = '' + firstPageSymbol + '' + separator; a = b = style; style = '' + previousPageSymbol + '' + separator; a += style; b += style; c += style; d += style } for (var i = 1; i <= lastPage; i++) { if (i == currentPage) { a += '' + i + '' + separator; b += '' + i + '/' + lastPage + '' + separator; c += '' + i + '' + separator; f += '' } else { style = '' + i + '' + separator; a += style; c += style; f += '' } } f += ''; if (currentPage == lastPage) { style = '' + nextPageSymbol + ''; a += style; b += style; c += style; d += style; style = separator + '' + lastPageSymbol + ''; a += style; b += style } else { style = '' + nextPageSymbol + ''; a += style; b += style; c += style; d += style; style = separator + '' + lastPageSymbol + ''; a += style; b += style } switch (paginatorStyle) { case 1: style = a; break; case 2: style = b; break; case 3: style = c; break; case 4: style = d; break; default: style = a } if (enablePageOfOption) style += '' + e + ''; if (enableGoToPage) style += '' + f + ''; if (enableSelectNoItems) style += '' + g + ''; jQuery(".paginator").html(style) }