filter widget fixes

This commit is contained in:
Mottie 2013-10-31 10:06:50 -05:00
parent ba7b0f3a40
commit deaee241fe
8 changed files with 32 additions and 51 deletions

View File

@ -44,6 +44,12 @@ tablesorter can successfully parse and sort many types of data including linked
View the [complete listing here](https://github.com/Mottie/tablesorter/wiki/Change). View the [complete listing here](https://github.com/Mottie/tablesorter/wiki/Change).
#### <a name="v2.13.1">Version 2.13.1</a> (10/31/2013)
* Fixed filter widget issues
* filter indexing will now be correct, even if a "tablesorter-filter" input/select doesn't exist in the filter row
* Already parsed filters (filter-formatter) will not attempt to reparse the value; problem was caused by parsed dates.
#### <a name="v2.13">Version 2.13</a> (10/30/2013) #### <a name="v2.13">Version 2.13</a> (10/30/2013)
* Added a "Development" branch to the repository. * Added a "Development" branch to the repository.
@ -223,26 +229,3 @@ View the [complete listing here](https://github.com/Mottie/tablesorter/wiki/Chan
**Thanks** **Thanks**
* Thanks to @thezoggy and @TheSin- for help maintaining and supporting the tablesorter github project while I was away! * Thanks to @thezoggy and @TheSin- for help maintaining and supporting the tablesorter github project while I was away!
* Also thanks to everyone else that contributed and even more thanks to those that helped troubleshoot and solve problems! * Also thanks to everyone else that contributed and even more thanks to those that helped troubleshoot and solve problems!
#### <a name="v2.10.8">Version 2.10.8</a> (6/3/2013)
* Updated the percent parser to only detect if the content is shorter than 15 characters. This prevents columns with a lot of content and one percent sign (%) from being set to be parsed as a percent numeric column. Fixes [issue #320](https://github.com/Mottie/tablesorter/issues/320).
* Updated filter widget &amp; filter_formatter:
* Added a new `filter_defaultAttrib` which points to the default `'data-value'` attribute in the table header which will contain the filter's default (starting) value and *will override* any set values within the filter_formatter functions. Updated the [custom filter widget function demo age column](http://mottie.github.io/tablesorter/docs/example-widget-filter-custom.html) to show this in action.
* The `$.tablesorter.setFilter()` method now properly updates the filter formatter elements when set.
* The `uiDateCompare` and `uiDatepicker` functions now adds a time of 11:59:59 to the "to" date or when a "less than" comparison is made so as to include all times within that selected day.
* The `defaultDate` option (not `date` option, sorry) of the `uiDateCompare` now properly sets the value upon initialization.
* The `from` and `to` options of the `uiDatepicker` now properly sets those values properly upon initialization.
* Fixes [issue #321](https://github.com/Mottie/tablesorter/issues/321).
* Fixed stickyHeaders widget:
* When removing a sticky headers widget, it no longer unbinds scrolling when other sticky headers are still active.
* Added `stickyHeaders_includeCaption` option (set as `true` by default). When this option is `false` and a caption exists, it will not be included in teh sticky header. Fixes [issue #322](https://github.com/Mottie/tablesorter/issues/322).
#### <a name="v2.10.7">Version 2.10.7</a> (5/31/2013)
* Now using correct `closest()` function equivalent. Thanks to [isuTony](https://github.com/isuTony); Fixes [issue #319](https://github.com/Mottie/tablesorter/issues/319).
* Anticipating my sabbitical, I've added a few "beta-testing" scripts into a new folder for feedback, code fixes and help:
* [Custom pager control script](http://mottie.github.io/tablesorter/beta-testing/example-pager-custom-controls.html) - should be working properly.
* [External filters using Select2 plugin](http://mottie.github.io/tablesorter/beta-testing/example-external-filters-using-select2.html) - should be working properly.
* [Column reorder widget](http://mottie.github.io/tablesorter/beta-testing/example-widget-column-reorder.html) - not working 100% with sticky headers.
* [Column sum widget](http://mottie.github.io/tablesorter/beta-testing/example-widget-sum-columns.html) - still needs LOTS of work!

View File

@ -1,6 +1,6 @@
{ {
"name": "tablesorter", "name": "tablesorter",
"version": "2.13.0", "version": "2.13.1",
"dependencies": { "dependencies": {
"jquery": ">=1.2.6" "jquery": ">=1.2.6"
} }

View File

@ -1,5 +1,5 @@
/**! /**!
* TableSorter 2.13.0 - Client-side table sorting with ease! * TableSorter 2.13.1 - Client-side table sorting with ease!
* @requires jQuery v1.2.6+ * @requires jQuery v1.2.6+
* *
* Copyright (c) 2007 Christian Bach * Copyright (c) 2007 Christian Bach
@ -24,7 +24,7 @@
var ts = this; var ts = this;
ts.version = "2.13.0"; ts.version = "2.13.1";
ts.parsers = []; ts.parsers = [];
ts.widgets = []; ts.widgets = [];

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! tableSorter 2.8+ widgets - updated 10/30/2013 /*! tableSorter 2.8+ widgets - updated 10/31/2013
* *
* Column Styles * Column Styles
* Column Filters * Column Filters
@ -399,7 +399,7 @@ ts.addWidget({
} }
}, },
findRows = function(filter, v, cv){ findRows = function(filter, v, cv){
var $tb, $tr, $td, cr, r, l, ff, time, r1, r2, searchFiltered; var $tb, $tr, $td, cr, r, l, ff, fr, time, r1, r2, searchFiltered;
if (c.debug) { time = new Date(); } if (c.debug) { time = new Date(); }
for (k = 0; k < b.length; k++ ){ for (k = 0; k < b.length; k++ ){
if (b.eq(k).hasClass(ts.css.info)) { continue; } // ignore info blocks, issue #264 if (b.eq(k).hasClass(ts.css.info)) { continue; } // ignore info blocks, issue #264
@ -477,11 +477,11 @@ ts.addWidget({
ff = val === '' ? true : !(wo.filter_startsWith ? s === 0 : s >= 0); ff = val === '' ? true : !(wo.filter_startsWith ? s === 0 : s >= 0);
// Look for operators >, >=, < or <= // Look for operators >, >=, < or <=
} else if (/^[<>]=?/.test(val)){ } else if (/^[<>]=?/.test(val)){
s = fmt(val.replace(wo.filter_regex.nondigit, '').replace(wo.filter_regex.operators,''), table); s = fr = fmt(val.replace(wo.filter_regex.nondigit, '').replace(wo.filter_regex.operators,''), table);
// parse filter value in case we're comparing numbers (dates) // parse filter value in case we're comparing numbers (dates)
if (parsed[i] || c.parsers[i].type === 'numeric') { if (parsed[i] || c.parsers[i].type === 'numeric') {
rg = c.parsers[i].format('' + val.replace(wo.filter_regex.operators,''), table, $ths.eq(i), i); rg = c.parsers[i].format('' + val.replace(wo.filter_regex.operators,''), table, $ths.eq(i), i);
s = (rg !== '' && !isNaN(rg)) ? rg : s; s = (isNaN(s) && rg !== '' && !isNaN(rg)) ? rg : s;
} }
// xi may be numeric - see issue #149; // xi may be numeric - see issue #149;
// check if c.cache[k].normalized[j] is defined, because sometimes j goes out of range? (numeric columns) // check if c.cache[k].normalized[j] is defined, because sometimes j goes out of range? (numeric columns)
@ -489,7 +489,7 @@ ts.addWidget({
isNaN(xi) ? fmt(xi.replace(wo.filter_regex.nondigit, ''), table) : fmt(xi, table); isNaN(xi) ? fmt(xi.replace(wo.filter_regex.nondigit, ''), table) : fmt(xi, table);
if (/>/.test(val)) { ff = />=/.test(val) ? rg >= s : rg > s; } if (/>/.test(val)) { ff = />=/.test(val) ? rg >= s : rg > s; }
if (/</.test(val)) { ff = /<=/.test(val) ? rg <= s : rg < s; } if (/</.test(val)) { ff = /<=/.test(val) ? rg <= s : rg < s; }
if (s === '') { ff = true; } // keep showing all rows if nothing follows the operator if (!ff && fr === '') { ff = true; } // keep showing all rows if nothing follows the operator
// Look for an AND or && operator (logical and) // Look for an AND or && operator (logical and)
} else if (/\s+(AND|&&)\s+/g.test(v[i])) { } else if (/\s+(AND|&&)\s+/g.test(v[i])) {
s = val.split(/(?:\s+(?:and|&&)\s+)/g); s = val.split(/(?:\s+(?:and|&&)\s+)/g);
@ -754,9 +754,7 @@ ts.addWidget({
// $(':focus') needs jQuery 1.6+ // $(':focus') needs jQuery 1.6+
if ($(document.activeElement).closest('tr')[0] !== ft[0]){ if ($(document.activeElement).closest('tr')[0] !== ft[0]){
// get all filter values // get all filter values
all = $t.find('.tablesorter-filter').map(function(){ all = ts.getFilters(table).join('');
return $(this).val() || '';
}).get().join('');
// don't hide row if any filter has a value // don't hide row if any filter has a value
if (all === ''){ if (all === ''){
ft.addClass('hideme'); ft.addClass('hideme');
@ -770,7 +768,7 @@ ts.addWidget({
clearTimeout(st); clearTimeout(st);
st = setTimeout(function(){ st = setTimeout(function(){
// don't hide row if any filter has a value // don't hide row if any filter has a value
if ($t.find('.tablesorter-filter').map(function(){ return $(this).val() || ''; }).get().join('') === ''){ if (ts.getFilters(table).join('') === ''){
ft2[ e.type === 'focus' ? 'removeClass' : 'addClass']('hideme'); ft2[ e.type === 'focus' ? 'removeClass' : 'addClass']('hideme');
} }
}, 200); }, 200);
@ -826,15 +824,15 @@ ts.addWidget({
ts.getFilters = function(table) { ts.getFilters = function(table) {
var c = table ? $(table)[0].config : {}; var c = table ? $(table)[0].config : {};
if (c && c.widgetOptions && !c.widgetOptions.filter_columnFilters) { return $(table).data('lastSearch'); } if (c && c.widgetOptions && !c.widgetOptions.filter_columnFilters) { return $(table).data('lastSearch'); }
return c && c.$filters ? c.$filters.find('.tablesorter-filter').map(function(i, el) { return c && c.$filters ? c.$filters.map(function(i, el) {
return $(el).val(); return $(el).find('.tablesorter-filter').val() || '';
}).get() || [] : false; }).get() || [] : false;
}; };
ts.setFilters = function(table, filter, apply) { ts.setFilters = function(table, filter, apply) {
var $t = $(table), var $t = $(table),
c = $t.length ? $t[0].config : {}, c = $t.length ? $t[0].config : {},
valid = c && c.$filters ? c.$filters.find('.tablesorter-filter').each(function(i, el) { valid = c && c.$filters ? c.$filters.each(function(i, el) {
$(el).val(filter[i] || ''); $(el).find('.tablesorter-filter').val(filter[i] || '');
}) || false : false; }) || false : false;
if (apply) { $t.trigger('search', [filter, false]); } if (apply) { $t.trigger('search', [filter, false]); }
return !!valid; return !!valid;

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"name": "tablesorter", "name": "tablesorter",
"title": "tablesorter", "title": "tablesorter",
"version": "2.13.0", "version": "2.13.1",
"description": "tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.\n\nThis forked version adds lots of new enhancements including: alphanumeric sorting, pager callback functons, multiple widgets providing column styling, ui theme application, sticky headers, column filters and resizer, as well as extended documentation with a lot more demos.", "description": "tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.\n\nThis forked version adds lots of new enhancements including: alphanumeric sorting, pager callback functons, multiple widgets providing column styling, ui theme application, sticky headers, column filters and resizer, as well as extended documentation with a lot more demos.",
"author": { "author": {
"name": "Christian Bach", "name": "Christian Bach",

View File

@ -1,7 +1,7 @@
{ {
"name": "tablesorter", "name": "tablesorter",
"title": "tablesorter", "title": "tablesorter",
"version": "2.13.0", "version": "2.13.1",
"description": "tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.\n\nThis forked version adds lots of new enhancements including: alphanumeric sorting, pager callback functons, multiple widgets providing column styling, ui theme application, sticky headers, column filters and resizer, as well as extended documentation with a lot more demos.", "description": "tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.\n\nThis forked version adds lots of new enhancements including: alphanumeric sorting, pager callback functons, multiple widgets providing column styling, ui theme application, sticky headers, column filters and resizer, as well as extended documentation with a lot more demos.",
"author": { "author": {
"name": "Christian Bach", "name": "Christian Bach",