Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Added disabled class. Fixes #7
Browse files Browse the repository at this point in the history
Thanks to Zikes (Jason Hutchinson), of which this is based on.
  • Loading branch information
beneverard committed Apr 11, 2012
1 parent 1c246a8 commit 6a36745
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
15 changes: 15 additions & 0 deletions css/jqpagination.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@

}

.pagination a.disabled, .pagination a.disabled:hover, .pagination a.disabled:focus, .pagination a.disabled:active {

background: #F3F3F3; /* Old browsers */
background: -moz-linear-gradient(top, #F3F3F3 0%, #D3D3D3 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#F3F3F3), color-stop(100%,#D3D3D3)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #F3F3F3 0%,#D3D3D3 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #F3F3F3 0%,#D3D3D3 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #F3F3F3 0%,#D3D3D3 100%); /* IE10+ */
background: linear-gradient(top, #F3F3F3 0%,#D3D3D3 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F3F3F3', endColorstr='#D3D3D3',GradientType=0 ); /* IE6-9 */

color: #A8A8A8;

}

.pagination a:first-child {
border-radius: 2px 0 0 2px;
-moz-border-radius: 2px 0 0 2px;
Expand Down
28 changes: 24 additions & 4 deletions js/jquery.jqpagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

base.options = $.extend({}, $.jqPagination.defaultOptions, options);

// if the user hasn't provided a max page number in the options try and find
// if the user hasn't provided a max page number in the options try and find
// the data attribute for it, if that cannot be found, use one as a max page number

if (base.options.max_page === null) {
Expand Down Expand Up @@ -113,10 +113,19 @@

base.$el.find('a').live('click', function (event) {

// for mac + windows (read: other), maintain the cmd + ctrl click for new tab
var $self = $(this);

// we don't want to do anything if we've clicked a disabled link
// return false so we stop normal link action btu also drop out of this event

if ($self.hasClass('disabled')) {
return false;
}

// for maintainac + windows (read: other), maintain the cmd + ctrl click for new tab
if (!event.metaKey && !event.ctrlKey) {
event.preventDefault();
base.setPage($(this).data('action'));
base.setPage($self.data('action'));
}

});
Expand Down Expand Up @@ -268,7 +277,18 @@
base.$el.find('a.last').attr('href', link_string.replace('{page_number}', max_page));

}


// set disable class on appropriate links
base.$el.find('a').removeClass('disabled');

if (current_page === max_page) {
base.$el.find('.next, .last').addClass('disabled');
}

if (current_page === 1) {
base.$el.find('.previous, .first').addClass('disabled');
}

};

base.option = function (key, value) {
Expand Down
2 changes: 1 addition & 1 deletion js/jquery.jqpagination.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a36745

Please sign in to comment.