diff --git a/beta-testing/example-pager-custom-controls.html b/beta-testing/example-pager-custom-controls.html
index 4d42d847..e4c745d1 100644
--- a/beta-testing/example-pager-custom-controls.html
+++ b/beta-testing/example-pager-custom-controls.html
@@ -63,9 +63,10 @@
aroundCurrent : 1, // number of pages surrounding the current page
link : '{page}', // page element; use {page} to include the page number
currentClass : 'current', // current page class name
- adjacentSpacer : ' | ', // spacer for page numbers next to each other
- distanceSpacer : ' \u2026 ', // spacer for page numbers away from each other (ellipsis …)
- addKeyboard : true // add left/right keyboard arrows to change current page
+ adjacentSpacer : ' | ', // spacer for page numbers next to each other
+ distanceSpacer : '
', // spacer for page numbers away from each other (ellipsis = …)
+ addKeyboard : true, // use left,right,up,down,pageUp,pageDown,home, or end to change current page
+ pageKeyStep : 10 // page step to use for pageUp and pageDown
});
// initialize tablesorter & pager
@@ -97,6 +98,20 @@
NOTE!
+ - Modified in v2.27.6
+
+ - Fixed issues with page less than one being shown.
+ - The
ends
and aroundCurrent
works properly when values are set to zero.
+ - Modified
adjacentSpacer
and distanceSpacer
to include surrounding span element.
+ - Using the keyboard has changed!
+
+ - NOTE The keyboard keys will only work IF a pager element has focus.
+ - The
addKeyboard
function now includes left, right, up, down, pageUp, pageDown, Home and End.
+ - A new
pageKeyStep
option was added to allow setting the number of pages to skip on pageUp or pageDown.
+
+
+
+
- Modified in v2.17.1 to properly work with either the pager addon or pager widget.
- In v2.16.4, code was updated to correctly count process pages.
diff --git a/beta-testing/pager-custom-controls.js b/beta-testing/pager-custom-controls.js
index 6c2406ee..a99b6b43 100644
--- a/beta-testing/pager-custom-controls.js
+++ b/beta-testing/pager-custom-controls.js
@@ -29,7 +29,8 @@ $.tablesorter.customPagerControls = function(settings) {
currentClass : 'current', // current page class name
adjacentSpacer : ' | ', // spacer for page numbers next to each other
distanceSpacer : '
', // spacer for page numbers away from each other (ellipsis)
- addKeyboard : true // add left/right keyboard arrows to change current page
+ addKeyboard : true, // use left,right,up,down,pageUp,pageDown,home, or end to change current page
+ pageKeyStep : 10 // page step to use for pageUp and pageDown
},
options = $.extend({}, defaults, settings),
$table = $(options.table),
@@ -84,7 +85,9 @@ $.tablesorter.customPagerControls = function(settings) {
}
$pager
.find('.pagecount')
- .html(pages.html());
+ .html(pages.html())
+ .find('.' + options.currentClass)
+ .focus();
});
// set up pager controls
@@ -113,23 +116,26 @@ $.tablesorter.customPagerControls = function(settings) {
if (options.addKeyboard) {
$(document).on('keydown', function(events) {
// ignore arrows inside form elements
- if (/input|select|textarea/i.test(events.target.nodeName)) {
+ if (/input|select|textarea/i.test(events.target.nodeName) ||
+ !(events.which > 32 && events.which < 41)) {
return;
}
- if (events.which === 37) {
- // left
- $pager
- .find(options.currentPage)
- .filter('.' + options.currentClass)
- .prevAll(':not(span):first')
- .click();
- } else if (events.which === 39) {
- // right
- $pager
- .find(options.currentPage)
- .filter('.' + options.currentClass)
- .nextAll(':not(span):first')
- .click();
+ // only allow keyboard use if element inside of pager is focused
+ if ($(document.activeElement).closest(options.pager).is($pager)) {
+ events.preventDefault();
+ var key = events.which,
+ max = $table[0].config.totalRows,
+ $el = $pager.find(options.currentPage).filter('.' + options.currentClass),
+ page = $el.length ? parseInt($el.attr('data-page'), 10) : null;
+ if (page) {
+ if (key === 33) { page -= options.pageKeyStep; } // pageUp
+ if (key === 34) { page += options.pageKeyStep; } // pageDown
+ if (key === 35) { page = max; } // end
+ if (key === 36) { page = 1; } // home
+ if (key === 37 || key === 38) { page -= 1; } // left/up
+ if (key === 39 || key === 40) { page += 1; } // right/down
+ $table.trigger('pageSet', page);
+ }
}
});
}
diff --git a/docs/js/docs.js b/docs/js/docs.js
index fff6b88d..9de5b959 100644
--- a/docs/js/docs.js
+++ b/docs/js/docs.js
@@ -5,13 +5,14 @@
var $t, t, v, animating, clicked,
cleanupCode = function(code){
- return code.replace(/[<>\"\'\t\n]/g, function(m) { return {
+ return code.replace(/([<>\"\'\t\n]|
)/g, function(m) { return {
'<' : '<',
'>' : '>',
"'" : ''',
'"' : '"',
'\t': ' ',
- '\n': '
' // needed for IE
+ '\n': '
', // needed for IE
+ '
' : '…' // pager custom controls ellipsis
}[m];});
};