Pager: change enable, disable & destroy trigger methods. Fixes #980

This commit is contained in:
Mottie 2015-07-30 13:32:54 -05:00
parent b697d08752
commit 7a288dd1bf
14 changed files with 77 additions and 57 deletions

View File

@ -114,7 +114,7 @@
};
var pagerEvents = 'filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete ' +
var pagerEvents = 'filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete ' +
'pageSize pageSet pageAndSize pagerUpdate refreshComplete ',
$this = this,
@ -909,15 +909,15 @@
c.$table.trigger('applyWidgets');
}
})
.bind('disable' + namespace, function(e){
.bind('disablePager' + namespace, function(e){
e.stopPropagation();
showAllRows(table, p);
})
.bind('enable' + namespace, function(e){
.bind('enablePager' + namespace, function(e){
e.stopPropagation();
enablePager(table, p, true);
})
.bind('destroy' + namespace, function(e){
.bind('destroyPager' + namespace, function(e){
e.stopPropagation();
destroyPager(table, p);
})

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! tablesorter (FORK) - updated 07-29-2015 (v2.22.5)*/
/*! tablesorter (FORK) - updated 07-30-2015 (v2.22.5)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) {
if (typeof define === 'function' && define.amd) {

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! tablesorter (FORK) - updated 07-29-2015 (v2.22.5)*/
/*! tablesorter (FORK) - updated 07-30-2015 (v2.22.5)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) {
if (typeof define === 'function' && define.amd) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -24,8 +24,9 @@
<script id="js">$(function(){
var $table = $('table'),
// define pager options
var pagerOptions = {
pagerOptions = {
// target the pager markup - see the HTML block below
container: $(".pager"),
// output string - default is '{page}/{totalPages}'; possible variables: {page}, {totalPages}, {startRow}, {endRow} and {totalRows}
@ -42,7 +43,7 @@
// Initialize tablesorter
// ***********************
$("table")
$table
.tablesorter({
theme: 'blue',
headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!
@ -74,7 +75,7 @@
});
num = num + 2;
$row = $(r);
$('table')
$table
.find('tbody').append($row)
.trigger('addRows', [$row]);
return false;
@ -82,14 +83,14 @@
// Delete a row
// *************
$('table').delegate('button.remove', 'click' ,function(){
var t = $('table');
$table.delegate('button.remove', 'click' ,function(){
// NOTE this special treatment is only needed if `removeRows` is `true`
// disabling the pager will restore all table rows
t.trigger('disable.pager');
$table.trigger('disablePager');
// remove chosen row
$(this).closest('tr').remove();
// restore pager
t.trigger('enable.pager');
$table.trigger('enablePager');
});
// Destroy pager / Restore pager
@ -98,10 +99,10 @@
// Exterminate, annhilate, destroy! http://www.youtube.com/watch?v=LOqn8FxuyFs
var $t = $(this);
if (/Destroy/.test( $t.text() )){
$('table').trigger('destroy.pager');
$table.trigger('destroyPager');
$t.text('Restore Pager');
} else {
$('table').tablesorterPager(pagerOptions);
$table.tablesorterPager(pagerOptions);
$t.text('Destroy Pager');
}
return false;
@ -111,11 +112,12 @@
// **************
$('.toggle').click(function(){
var mode = /Disable/.test( $(this).text() );
$('table').trigger( (mode ? 'disable' : 'enable') + '.pager');
// triggering disablePager or enablePager
$table.trigger( (mode ? 'disable' : 'enable') + 'Pager');
$(this).text( (mode ? 'Enable' : 'Disable') + 'Pager');
return false;
});
$('table').bind('pagerChange', function(){
$table.bind('pagerChange', function(){
// pager automatically enables when table is sorted.
$('.toggle').text('Disable');
});
@ -135,6 +137,13 @@
<p class="tip">
<em>NOTE!</em> The following are not part of the original plugin:
<ul>
<li>In <span class="version updated">v2.23.0</span>, the following methods were changed due to issues with unique namespacing.
<ul>
<li><code>destroy.pager</code> is now <code>destroyPager</code></li>
<li><code>disable.pager</code> is now <code>disablePager</code></li>
<li><code>enable.pager</code> is now <code>enablePager</code></li>
</ul>
</li>
<li>When using this pager plugin with the filter widget, make sure that the <code>removeRows</code> option is set to <code>false</code> or it won't work.</li>
<li>This combination was not possible in tablesorter versions prior to version 2.4.</li>
<li>This combination can not be applied to the original tablesorter.</li>

View File

@ -157,11 +157,11 @@
$('table').delegate('button.remove', 'click' ,function(){
var t = $('table');
// disabling the pager will restore all table rows
// t.trigger('disable.pager');
// t.trigger('disablePager');
// remove chosen row
$(this).closest('tr').remove();
// restore pager
// t.trigger('enable.pager');
// t.trigger('enablePager');
t.trigger('update');
return false;
});
@ -172,7 +172,7 @@
// Exterminate, annhilate, destroy! http://www.youtube.com/watch?v=LOqn8FxuyFs
var $t = $(this);
if (/Destroy/.test( $t.text() )){
$('table').trigger('destroy.pager');
$('table').trigger('destroyPager');
$t.text('Restore Pager');
} else {
$('table').tablesorterPager(pagerOptions);
@ -185,7 +185,7 @@
// **************
$('.toggle').click(function(){
var mode = /Disable/.test( $(this).text() );
$('table').trigger( (mode ? 'disable' : 'enable') + '.pager');
$('table').trigger( (mode ? 'disable' : 'enable') + 'Pager');
$(this).text( (mode ? 'Enable' : 'Disable') + 'Pager');
return false;
});
@ -231,6 +231,13 @@
<p class="tip">
<em>NOTE!</em> The following are not part of the original plugin:
<ul>
<li>In <span class="version updated">v2.23.0</span>, the following methods were changed due to issues with unique namespacing.
<ul>
<li><code>destroy.pager</code> is now <code>destroyPager</code></li>
<li><code>disable.pager</code> is now <code>disablePager</code></li>
<li><code>enable.pager</code> is now <code>enablePager</code></li>
</ul>
</li>
<li>In <span class="version">v2.19.0</span>, added <code>pageAndSize</code> method which allows setting both the pager page &amp; size.</li>
<li>In <span class="version">v2.17.6</span>, added <code>{startRow:input}</code> and <code>{page:input}</code> variables to the <code>output</code> option.</li>
<li>This pager plugin can be applied to the original tablesorter, but there is one exception - setting the <code>removeRows</code> option to false will break the sort.</li>

View File

@ -24,7 +24,9 @@
<script id="js">$(function(){
$("table")
var $table = $('table');
$table
// Initialize tablesorter
// ***********************
@ -145,7 +147,7 @@
});
num = num + 2;
$row = $(r);
$('table')
$table
.find('tbody').append($row)
.trigger('addRows', [$row]);
return false;
@ -153,15 +155,14 @@
// Delete a row
// *************
$('table').delegate('button.remove', 'click' ,function(){
var t = $('table');
$table.delegate('button.remove', 'click' ,function(){
// disabling the pager will restore all table rows
// t.trigger('disable.pager');
// $table.trigger('disablePager');
// remove chosen row
$(this).closest('tr').remove();
// restore pager
// t.trigger('enable.pager');
t.trigger('update');
// $table.trigger('enablePager');
$table.trigger('update');
return false;
});
@ -171,13 +172,13 @@
// Exterminate, annhilate, destroy! http://www.youtube.com/watch?v=LOqn8FxuyFs
var $t = $(this);
if (/Destroy/.test( $t.text() )){
$('table')[0].config.widgets = ['zebra'];
$('table').trigger('refreshWidgets');
//.trigger('destroy.pager');
$table[0].config.widgets = ['zebra'];
$table.trigger('refreshWidgets');
//.trigger('destroyPager');
$t.text('Restore Pager');
} else {
$('table')[0].config.widgets = ['zebra', 'pager'];
$('table').trigger('applyWidgets');
$table[0].config.widgets = ['zebra', 'pager'];
$table.trigger('applyWidgets');
$t.text('Destroy Pager');
}
return false;
@ -187,11 +188,12 @@
// **************
$('.toggle').click(function(){
var mode = /Disable/.test( $(this).text() );
$('table').trigger( (mode ? 'disable' : 'enable') + '.pager');
// using disablePager or enablePager
$table.trigger( (mode ? 'disable' : 'enable') + 'Pager');
$(this).text( (mode ? 'Enable' : 'Disable') + 'Pager');
return false;
});
$('table').bind('pagerChange', function(){
$table.bind('pagerChange', function(){
// pager automatically enables when table is sorted.
$('.toggle').text('Disable Pager');
});
@ -200,7 +202,7 @@
$('.clear-pager-data').click(function(){
// clears user set page & size from local storage, so on page
// reload the page & size resets to the original settings
$.tablesorter.storage( $('table'), 'tablesorter-pager', '' );
$.tablesorter.storage( $table, 'tablesorter-pager', '' );
});
// go to page 1 showing 10 rows
@ -208,7 +210,7 @@
// triggering "pageAndSize" without parameters will reset the
// pager to page 1 and the original set size (10 by default)
// $('table').trigger('pageAndSize')
$('table').trigger('pageAndSize', [1, 10]);
$table.trigger('pageAndSize', [1, 10]);
});
});</script>

View File

@ -5074,11 +5074,12 @@ $('table').trigger( 'search', [['', '', '', '', 'orange']] ); // find orange in
</tr>
<tr id="destroypager">
<td><a href="#" class="permalink">destroy.pager</a></td>
<td>Calling this method will reveal the entire table, remove the pager functionality, and hide the actual pager (v2.0.16).
<td><a href="#" class="permalink">destroyPager</a></td>
<td>Calling this method will reveal the entire table, remove the pager functionality, and hide the actual pager (v2.0.16; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>destroy.pager</code> to <code>destroyPager</code> because of issues with unique namespacing.</p>
<pre class="prettyprint lang-js">$(function(){
$('table').trigger('destroy.pager');
$('table').trigger('destroyPager');
});</pre>
The only way to restore the pager is to re-initialize the pager addon
<br>
@ -5090,25 +5091,26 @@ $('table').trigger( 'search', [['', '', '', '', 'orange']] ); // find orange in
</tr>
<tr id="disablepager">
<td><a href="#" class="permalink">disable.pager</a></td>
<td>This method will put the pager into a disabled state (v2.0.21.2).
<td><a href="#" class="permalink">disablePager</a></td>
<td>This method will put the pager into a disabled state (v2.0.21.2; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<br>
<p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>disable.pager</code> to <code>disablePager</code> because of issues with unique namespacing.</p>
The disabled state will reveal all table rows and disable, but not hide, pager controls.
<br>
<pre class="prettyprint lang-js">$(function(){
$('table').trigger('disable.pager');
$('table').trigger('disablePager');
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="enablepager">
<td><a href="#" class="permalink">enable.pager</a></td>
<td>This method will re-enable the pager, but only from the disabled state (v2.0.21.2).
<td><a href="#" class="permalink">enablePager</a></td>
<td>This method will re-enable the pager, but only from the disabled state (v2.0.21.2; <span class="version updated">v2.23.0</span>).
<div class="collapsible">
<p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>enable.pager</code> to <code>enablePager</code> because of issues with unique namespacing.</p>
<pre class="prettyprint lang-js">$(function(){
$('table').trigger('enable.pager');
$('table').trigger('enablePager');
});</pre></div>
</td>
<td><a href="example-pager.html">Example</a></td>

View File

@ -4,7 +4,7 @@
*/
/*! tablesorter (FORK) - updated 07-29-2015 (v2.22.5)*/
/*! tablesorter (FORK) - updated 07-30-2015 (v2.22.5)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -4,7 +4,7 @@
*/
/*! tablesorter (FORK) - updated 07-29-2015 (v2.22.5)*/
/*! tablesorter (FORK) - updated 07-30-2015 (v2.22.5)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -145,7 +145,7 @@
// save original pager size
setSize: wo.pager_size,
setPage: wo.pager_startPage,
events: 'filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete ' +
events: 'filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete ' +
'pageSize pageSet pageAndSize pagerUpdate refreshComplete '
}, c.pager);
@ -257,15 +257,15 @@
c.$table.trigger('applyWidgets');
}
})
.on('disable' + namespace, function(e){
.on('disablePager' + namespace, function(e){
e.stopPropagation();
tsp.showAllRows(table, c);
})
.on('enable' + namespace, function(e){
.on('enablePager' + namespace, function(e){
e.stopPropagation();
tsp.enablePager(table, c, true);
})
.on('destroy' + namespace, function(e, refreshing){
.on('destroyPager' + namespace, function(e, refreshing){
e.stopPropagation();
tsp.destroyPager(table, c, refreshing);
})