Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added "disabled" classes #7

Closed
wants to merge 1 commit into from

2 participants

@zikes

When at the first and last page the appropriate buttons will have a disabled class applied.

I've also included stylings in the demo.

@beneverard beneverard closed this pull request from a commit
@beneverard Added disabled class. Fixes #7
Thanks to Zikes (Jason Hutchinson), of which this is based on.
6a36745
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 28 additions and 3 deletions.
  1. +18 −0 css/jqpagination.css
  2. +10 −3 js/jquery.jqpagination.js
View
18 css/jqpagination.css
@@ -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;
View
13 js/jquery.jqpagination.js
@@ -118,7 +118,8 @@
}
});
-
+
+ base.setLinks();
};
base.setPage = function (page) {
@@ -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);
@@ -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),
@@ -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');
+ }
}
};
Something went wrong with that request. Please try again.