From 386d6ab5af3bdee87d33e4c2deb737711eb48285 Mon Sep 17 00:00:00 2001
From: Mottie
Date: Wed, 28 May 2014 11:14:37 -0500
Subject: [PATCH] Pager: custom controls example updated to work with pager
widget. Fixes #631
---
beta-testing/example-pager-custom-controls.html | 1 +
beta-testing/pager-custom-controls.js | 15 +++++++++------
docs/index.html | 2 +-
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/beta-testing/example-pager-custom-controls.html b/beta-testing/example-pager-custom-controls.html
index 082f694b..c044b3f3 100644
--- a/beta-testing/example-pager-custom-controls.html
+++ b/beta-testing/example-pager-custom-controls.html
@@ -97,6 +97,7 @@
NOTE!
+ - 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 4e2c1434..194bc0d2 100644
--- a/beta-testing/pager-custom-controls.js
+++ b/beta-testing/pager-custom-controls.js
@@ -36,18 +36,21 @@ $.tablesorter.customPagerControls = function(settings) {
$table
.on('pagerInitialized pagerComplete', function (e, c) {
- var indx, pages = $(''), pageArray = [],
- cur = c.page + 1,
- start = cur > 1 ? (c.filteredPages - cur < options.aroundCurrent ? -(options.aroundCurrent + 1) + (c.filteredPages - cur) : -options.aroundCurrent) : 0,
- end = cur < options.aroundCurrent + 1 ? options.aroundCurrent + 3 - cur : options.aroundCurrent + 1;
+ var indx,
+ p = c.pager ? c.pager : c, // using widget
+ pages = $(''),
+ pageArray = [],
+ cur = p.page + 1,
+ start = cur > 1 ? (p.filteredPages - cur < options.aroundCurrent ? -(options.aroundCurrent + 1) + (p.filteredPages - cur) : -options.aroundCurrent) : 0,
+ end = cur < options.aroundCurrent + 1 ? options.aroundCurrent + 3 - cur : options.aroundCurrent + 1;
for (indx = start; indx < end; indx++) {
- if (cur + indx >= 1 && cur + indx < c.filteredPages) { pageArray.push( cur + indx ); }
+ if (cur + indx >= 1 && cur + indx < p.filteredPages) { pageArray.push( cur + indx ); }
}
if (pageArray.length) {
// include first and last pages (ends) in the pagination
for (indx = 0; indx < options.ends; indx++){
if ($.inArray(indx + 1, pageArray) === -1) { pageArray.push(indx + 1); }
- if ($.inArray(c.filteredPages - indx, pageArray) === -1) { pageArray.push(c.filteredPages - indx); }
+ if ($.inArray(p.filteredPages - indx, pageArray) === -1) { pageArray.push(p.filteredPages - indx); }
}
// sort the list
pageArray = pageArray.sort(function(a, b){ return a - b; });
diff --git a/docs/index.html b/docs/index.html
index 1fb5fe0d..d25ed70b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -532,7 +532,7 @@
Work-in-progress