mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Switched method to save last search time. Fixes #473
This commit is contained in:
parent
15bf11f0d4
commit
5a18cd646a
@ -1,4 +1,4 @@
|
|||||||
/*! tableSorter 2.8+ widgets - updated 2/19/2014 (v2.15.0)
|
/*! tableSorter 2.8+ widgets - updated 2/19/2014 (v2.15.1)
|
||||||
*
|
*
|
||||||
* Column Styles
|
* Column Styles
|
||||||
* Column Filters
|
* Column Filters
|
||||||
@ -581,10 +581,6 @@ ts.filter = {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
ts.filter.bindSearch( table, c.$table.find('input.' + ts.css.filter), true );
|
|
||||||
if (wo.filter_external) {
|
|
||||||
ts.filter.bindSearch( table, wo.filter_external );
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset button/link
|
// reset button/link
|
||||||
if (wo.filter_reset) {
|
if (wo.filter_reset) {
|
||||||
@ -621,9 +617,10 @@ ts.filter = {
|
|||||||
// it would append the same options twice.
|
// it would append the same options twice.
|
||||||
ts.filter.buildDefault(table, true);
|
ts.filter.buildDefault(table, true);
|
||||||
|
|
||||||
c.$table.find('select.' + ts.css.filter).bind('change search', function(event, filter) {
|
ts.filter.bindSearch( table, c.$table.find('.' + ts.css.filter), true );
|
||||||
ts.filter.checkFilters(table, filter, true);
|
if (wo.filter_external) {
|
||||||
});
|
ts.filter.bindSearch( table, wo.filter_external );
|
||||||
|
}
|
||||||
|
|
||||||
if (wo.filter_hideFilters) {
|
if (wo.filter_hideFilters) {
|
||||||
ts.filter.hideFilters(table, c);
|
ts.filter.hideFilters(table, c);
|
||||||
@ -746,11 +743,12 @@ ts.filter = {
|
|||||||
ts.setFilters(table, c.$table.data('lastSearch') || [], internal === false);
|
ts.setFilters(table, c.$table.data('lastSearch') || [], internal === false);
|
||||||
}
|
}
|
||||||
$el
|
$el
|
||||||
.data('lastSearchTime', new Date().getTime())
|
// use data attribute instead of jQuery data since the head is cloned without including the data/binding
|
||||||
|
.attr('data-lastSearchTime', new Date().getTime())
|
||||||
.unbind('keyup search change')
|
.unbind('keyup search change')
|
||||||
// include change for select - fixes #473
|
// include change for select - fixes #473
|
||||||
.bind('keyup search change', function(event, filters) {
|
.bind('keyup search change', function(event, filters) {
|
||||||
$(this).data('lastSearchTime', new Date().getTime());
|
$(this).attr('data-lastSearchTime', new Date().getTime());
|
||||||
// emulate what webkit does.... escape clears the filter
|
// emulate what webkit does.... escape clears the filter
|
||||||
if (event.which === 27) {
|
if (event.which === 27) {
|
||||||
this.value = '';
|
this.value = '';
|
||||||
@ -1112,7 +1110,7 @@ ts.getFilters = function(table, getRaw, setFilters, skipFirst) {
|
|||||||
if ($column.length) {
|
if ($column.length) {
|
||||||
// move the latest search to the first slot in the array
|
// move the latest search to the first slot in the array
|
||||||
$column = $column.sort(function(a, b){
|
$column = $column.sort(function(a, b){
|
||||||
return $(a).data('lastSearchTime') <= $(b).data('lastSearchTime');
|
return $(a).attr('data-lastSearchTime') <= $(b).attr('data-lastSearchTime');
|
||||||
});
|
});
|
||||||
if ($.isArray(setFilters)) {
|
if ($.isArray(setFilters)) {
|
||||||
// skip first (latest input) to maintain cursor position while typing
|
// skip first (latest input) to maintain cursor position while typing
|
||||||
|
7
js/jquery.tablesorter.widgets.min.js
vendored
7
js/jquery.tablesorter.widgets.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user