Pager-custom-controls: spacer settings now include wrapper element

This commit is contained in:
Rob Garrison 2016-08-23 22:54:18 -05:00
parent a4ad8fd7b3
commit d18d2834ed
No known key found for this signature in database
GPG Key ID: 0A42D160D71978E1

View File

@ -27,8 +27,8 @@ $.tablesorter.customPagerControls = function(settings) {
aroundCurrent : 1, // number of pages surrounding the current page aroundCurrent : 1, // number of pages surrounding the current page
link : '<a href="#">{page}</a>', // page element; use {page} to include the page number link : '<a href="#">{page}</a>', // page element; use {page} to include the page number
currentClass : 'current', // current page class name currentClass : 'current', // current page class name
adjacentSpacer : ' | ', // spacer for page numbers next to each other adjacentSpacer : '<span> | </span>', // spacer for page numbers next to each other
distanceSpacer : ' &#133; ', // spacer for page numbers away from each other (ellipsis) distanceSpacer : '<span> &#133; <span>', // spacer for page numbers away from each other (ellipsis)
addKeyboard : true // add left/right keyboard arrows to change current page addKeyboard : true // add left/right keyboard arrows to change current page
}, },
options = $.extend({}, defaults, settings), options = $.extend({}, defaults, settings),
@ -70,9 +70,15 @@ $.tablesorter.customPagerControls = function(settings) {
max = pageArray.length - 1; max = pageArray.length - 1;
$.each(pageArray, function(indx, value) { $.each(pageArray, function(indx, value) {
pages pages
.append( $(options.link.replace(/\{page\}/g, value)).toggleClass(options.currentClass, value === cur).attr('data-page', value) ) .append(
.append( '<span>' + (indx < pageArray.length - 1 && ( pageArray[ indx + 1 ] - 1 !== value ) ? options.distanceSpacer : $(options.link.replace(/\{page\}/g, value))
( indx >= pageArray.length - 1 ? '' : options.adjacentSpacer )) + '</span>' ); .toggleClass(options.currentClass, value === cur)
.attr('data-page', value)
)
.append((indx < max && (pageArray[ indx + 1 ] - 1 !== value) ?
options.distanceSpacer :
(indx >= max ? '' : options.adjacentSpacer)
));
}); });
} }
} }