Skip to content

Commit

Permalink
added feature and styling to disable appropriate links at 0 and max_page
Browse files Browse the repository at this point in the history
  • Loading branch information
zikes committed Dec 16, 2011
1 parent 03e699d commit 4578e3b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
18 changes: 18 additions & 0 deletions css/jqpagination.css
Expand Up @@ -75,6 +75,24 @@
.pagination a:last-child {
border: none;
}
.pagination a.disabled{
color:#CCC;
cursor:default;
}
.pagination a.disabled:hover{
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(221,221,221)),
color-stop(1, rgb(243,243,243))
);
background-image: -moz-linear-gradient(
center bottom,
rgb(221,221,221) 0%,
rgb(243,243,243) 100%
);
}

.pagination input {
border: none;
Expand Down
13 changes: 10 additions & 3 deletions js/jquery.jqpagination.js
Expand Up @@ -118,7 +118,8 @@
}

});


base.setLinks();
};

base.setPage = function (page) {
Expand Down Expand Up @@ -167,7 +168,7 @@
base.setInputValue(page);

// set the link href attributes
base.setLinks(page);
base.setLinks();

// fire the callback function with the current page
base.options.paged(page);
Expand Down Expand Up @@ -199,7 +200,7 @@
return !isNaN(parseFloat(n)) && isFinite(n);
};

base.setLinks = function (page) {
base.setLinks = function () {

var link_string = base.options.link_string,
current_page = parseInt(base.options.current_page, 10),
Expand All @@ -225,6 +226,12 @@
base.$el.find('a.next').attr('href', link_string.replace('{page_number}', next));
base.$el.find('a.last').attr('href', link_string.replace('{page_number}', max_page));

base.$el.find('a').removeClass('disabled');
if(current_page <= 1){
base.$el.find('a.first, a.prev, a.previous').addClass('disabled').removeAttr('href');
}else if(current_page >= max_page){
base.$el.find('a.next, a.last').addClass('disabled').removeAttr('href');
}
}

};
Expand Down

0 comments on commit 4578e3b

Please sign in to comment.