Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 53 additions & 10 deletions lib/jquery.easyPaginate.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ $.fn.easyPaginate = function (options) {
prevButton: true,
prevButtonText: '<',
nextButton: true,
nextButtonText: '>'
nextButtonText: '>',
navElement: 'div', // 'ul' for ul > li > a, 'div' for div > a
navElementClass: '',
}

return this.each (function (instance) {
Expand All @@ -56,29 +58,70 @@ $.fn.easyPaginate = function (options) {
};

var displayNav = function() {
htmlNav = '<div class="easyPaginateNav">';

if(plugin.settings.firstButton) {
var navElementClass = plugin.settings.navElementClass === ''
? 'easyPaginateNav'
: 'easyPaginateNav ' + plugin.settings.navElementClass;
if (plugin.settings.navElement === 'ul') {
htmlNav = '<ul class="' + navElementClass + '">';
} else {
htmlNav = '<div class="' + navElementClass + '">';
}

if (plugin.settings.firstButton) {
if (plugin.settings.navElement === 'ul') {
htmlNav += '<li>';
}
htmlNav += '<a href="#'+plugin.settings.hashPage+':1" title="First page" rel="1" class="first">'+plugin.settings.firstButtonText+'</a>';
if (plugin.settings.navElement === 'ul') {
htmlNav += '</li>';
}
}

if(plugin.settings.prevButton) {
if (plugin.settings.prevButton) {
if (plugin.settings.navElement === 'ul') {
htmlNav += '<li>';
}
htmlNav += '<a href="" title="Previous" rel="" class="prev">'+plugin.settings.prevButtonText+'</a>';
if (plugin.settings.navElement === 'ul') {
htmlNav += '</li>';
}
}

for(i = 1;i <= plugin.settings.pages;i++) {
for (i = 1;i <= plugin.settings.pages;i++) {
if (plugin.settings.navElement === 'ul') {
htmlNav += '<li>';
}
htmlNav += '<a href="#'+plugin.settings.hashPage+':'+i+'" title="Page '+i+'" rel="'+i+'" class="page">'+i+'</a>';
if (plugin.settings.navElement === 'ul') {
htmlNav += '</li>';
}
};

if(plugin.settings.nextButton) {
if (plugin.settings.nextButton) {
if (plugin.settings.navElement === 'ul') {
htmlNav += '<li>';
}
htmlNav += '<a href="" title="Next" rel="" class="next">'+plugin.settings.nextButtonText+'</a>';
if (plugin.settings.navElement === 'ul') {
htmlNav += '</li>';
}
}

if(plugin.settings.lastButton) {
if (plugin.settings.lastButton) {
if (plugin.settings.navElement === 'ul') {
htmlNav += '<li>';
}
htmlNav += '<a href="#'+plugin.settings.hashPage+':'+plugin.settings.pages+'" title="Last page" rel="'+plugin.settings.pages+'" class="last">'+plugin.settings.lastButtonText+'</a>';
if (plugin.settings.navElement === 'ul') {
htmlNav += '</li>';
}
}

if (plugin.settings.navElement === 'ul') {
htmlNav += '</ul>';
} else {
htmlNav += '</div>';
}

htmlNav += '</div>';
plugin.nav = $(htmlNav);
plugin.nav.css({
'width': plugin.el.width()
Expand Down