diff --git a/js/widgets/widget-filter.js b/js/widgets/widget-filter.js index 52510dfb..e3364a86 100644 --- a/js/widgets/widget-filter.js +++ b/js/widgets/widget-filter.js @@ -1209,7 +1209,8 @@ c.$headerIndexed[ columnIndex ].hasClass( 'filter-parsed' ) ); vars.functions[ columnIndex ] = - ts.getColumnData( table, wo.filter_functions, columnIndex ); + ts.getColumnData( table, wo.filter_functions, columnIndex ) || + c.$headerIndexed[ columnIndex ].hasClass( 'filter-select' ); vars.defaultColFilter[ columnIndex ] = ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || ''; vars.excludeFilter[ columnIndex ] = diff --git a/testing/testing-widgets.js b/testing/testing-widgets.js index 405d364f..6ade7c33 100644 --- a/testing/testing-widgets.js +++ b/testing/testing-widgets.js @@ -45,31 +45,53 @@ jQuery(function($){ this.ts = $.tablesorter; // filter widget table - this.$table = $('#testblock').html('' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
RankFirst NameLast NameAgeTotalDiscountDateLast Name2
1Philip Aaron WongJohnson Sr Esq25$5.9522%Jun 26, 2004 7:22 AMJohnson Sr Esq
11AaronHibert12$2.995%Aug 21, 2009 12:21 PMHibert
12Brandon ClarkHenry Jr51$42.2918%Oct 13, 2000 1:15 PMHenry Jr
111PeterParker28$9.9920%Jul 6, 2006 8:14 AMParker
21JohnHood33$19.9925%Dec 10, 2002 5:14 AMHood
013ClarkKent Sr.18$15.8944%Jan 12, 2003 11:14 AMKent Sr.
005BruceAlmighty Esq45$153.1944%Jan 18, 2021 9:12 AMAlmighty Esq
10AlexDumass13$5.294%Jan 8, 2012 5:11 PMDumass
16JimFranco24$14.1914%Jan 14, 2004 11:23 AMFranco
166Bruce LeeEvans22$13.1911%Jan 18, 2007 9:12 AMEvans
100Brenda DexterMcMasters18$55.2015%Feb 12, 2010 7:23 PMMcMasters
55DennisBronson65$123.00Jan 20, 2001 1:12 PMBronson
9MarthadelFuego25$22.0917%Jun 11, 2011 10:55 AMdelFuego
').find('table'); + if ( /\(table2\)/.test(assert.test.testName) ) { + this.$table = $('#testblock').html('' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
AlphaNumericNumericAnimalsSites
abc1Koalahttp://www.google.com
abc 1234Oxhttp://www.yahoo.com
abc 9111Girafeehttp://www.facebook.com
zyx 24123Bisonhttp://www.whitehouse.gov/
abc 113Chimphttp://www.ucla.edu/
abc 256Elephanthttp://www.wikipedia.org/
abc 9155Lionhttp://www.nytimes.com/
ABC 1087Zebrahttp://www.google.com
zyx 1999Koalahttp://www.mit.edu/
zyx 120Llamahttp://www.nasa.gov/
').find('table'); + } else { + this.$table = $('#testblock').html('' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
RankFirst NameLast NameAgeTotalDiscountDateLast Name2
1Philip Aaron WongJohnson Sr Esq25$5.9522%Jun 26, 2004 7:22 AMJohnson Sr Esq
11AaronHibert12$2.995%Aug 21, 2009 12:21 PMHibert
12Brandon ClarkHenry Jr51$42.2918%Oct 13, 2000 1:15 PMHenry Jr
111PeterParker28$9.9920%Jul 6, 2006 8:14 AMParker
21JohnHood33$19.9925%Dec 10, 2002 5:14 AMHood
013ClarkKent Sr.18$15.8944%Jan 12, 2003 11:14 AMKent Sr.
005BruceAlmighty Esq45$153.1944%Jan 18, 2021 9:12 AMAlmighty Esq
10AlexDumass13$5.294%Jan 8, 2012 5:11 PMDumass
16JimFranco24$14.1914%Jan 14, 2004 11:23 AMFranco
166Bruce LeeEvans22$13.1911%Jan 18, 2007 9:12 AMEvans
100Brenda DexterMcMasters18$55.2015%Feb 12, 2010 7:23 PMMcMasters
55DennisBronson65$123.00Jan 20, 2001 1:12 PMBronson
9MarthadelFuego25$22.0917%Jun 11, 2011 10:55 AMdelFuego
').find('table'); + } + this.table = this.$table[0]; this.init = false; @@ -85,8 +107,8 @@ jQuery(function($){ filter_functions : { '.last2' : true, '.rank' : { - "< 10" : function(e, n) { return n <= 10; }, - "> 10" : function(e, n) { return n > 10; } + '< 10' : function(e, n) { return n <= 10; }, + '> 10' : function(e, n) { return n > 10; } } }, filter_selectSource : { @@ -322,8 +344,31 @@ jQuery(function($){ opts.push( $.trim( $(this).text() ) ); }); assert.equal ( 'len=' + opts.length + ',' + opts.join(''), 'len=4,abcdefzyx', 'filter_selectSource set' ); - }); + QUnit.test( 'Filter: select & matching (table2)', function(assert) { + var self = this, + ts = this.ts, + $table = this.$table, + table = this.table; + expect(3); + + return QUnit.SequentialRunner( + function(actions, assertions) { + return QUnit.assertOnEvent($table, 'filterEnd', actions, assertions); + } + ).nextTask( + function(){ ts.setFilters( table, ['abc 1'], true ); }, + function(){ assert.cacheCompare( table, 0, ['abc 1'], 'select exact search', true ); } + ).nextTask( + function(){ + $table.find( '.filter-select' ).eq(0).addClass( 'filter-match' ); + ts.setFilters( table, [ 'abc 1' ], true ); }, + function(){ assert.cacheCompare( table, 0, ['abc 1', 'abc 11', 'ABC 10'], 'select match search', true ); } + ).nextTask( + function(){ ts.setFilters( table, ['', '1'], true ); }, + function(){ assert.cacheCompare( table, 1, [ 1, 111, 123, 155], 'select match seach', true ); } + ).promise(); + }); }); diff --git a/testing/testing.js b/testing/testing.js index 877f46b1..f14a3cd1 100644 --- a/testing/testing.js +++ b/testing/testing.js @@ -45,7 +45,7 @@ QUnit.SequentialRunner = function(runnerCreator){ next: function(runner) { this.defer = this.defer.then( QUnit.deferredCallback(runner) ); return this; - }, + } }; if (runnerCreator) { result.nextTask = function(args) { // any argument list