Permalink
Browse files

Pager: custom controls example updated to work with pager widget. Fixes

  • Loading branch information...
1 parent d654a18 commit 386d6ab5af3bdee87d33e4c2deb737711eb48285 @Mottie committed May 28, 2014
Showing with 11 additions and 7 deletions.
  1. +1 −0 beta-testing/example-pager-custom-controls.html
  2. +9 −6 beta-testing/pager-custom-controls.js
  3. +1 −1 docs/index.html
View
1 beta-testing/example-pager-custom-controls.html
@@ -97,6 +97,7 @@
<p class="tip">
<em>NOTE!</em>
<ul>
+ <li>Modified in <span class="version">v2.17.1</span> to properly work with either the pager addon or pager widget.</li>
<li>In <span class="version">v2.16.4</span>, code was updated to correctly count process pages.</li>
</ul>
</p>
View
15 beta-testing/pager-custom-controls.js
@@ -36,18 +36,21 @@ $.tablesorter.customPagerControls = function(settings) {
$table
.on('pagerInitialized pagerComplete', function (e, c) {
- var indx, pages = $('<div/>'), 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 = $('<div/>'),
+ 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; });
View
2 docs/index.html
@@ -532,7 +532,7 @@ <h4 id="extras">Custom Parsers</h4>
<h4>Work-in-progress</h4>
<ul>
- <li><span class="label label-info">Beta</span> <a href="../beta-testing/example-pager-custom-controls.html">Custom pager control script</a></li>
+ <li><span class="label label-info">Beta</span> <a href="../beta-testing/example-pager-custom-controls.html">Custom pager control script</a> (<span class="version updated">v2.17.1</span>)</li>
<li><span class="label label-info">Alpha</span> <a href="../beta-testing/example-widget-column-reorder.html">Column reorder widget</a> - not working 100% with sticky headers</li>
</ul>

0 comments on commit 386d6ab

Please sign in to comment.