diff --git a/docs/example-widget-filter-formatter-1.html b/docs/example-widget-filter-formatter-1.html index 025a31a0..f9c9b539 100644 --- a/docs/example-widget-filter-formatter-1.html +++ b/docs/example-widget-filter-formatter-1.html @@ -49,6 +49,7 @@ value: 0, min: 0, max: 100, + delayed: true, valueToHeader: false }); }, @@ -57,6 +58,7 @@ values: [1, 70], min: 1, max: 70, + delayed: true, valueToHeader: false }); }, @@ -66,6 +68,7 @@ max : 45, value: 1, step: 1, + delayed: true, addToggle: true, exactMatch: true, numberFormat: "n" @@ -85,6 +88,7 @@ values: [1, 160], min: 1, max: 160, + delayed: true, valueToHeader: false }); } @@ -144,6 +148,7 @@ value: 0, // starting value min: 0, // minimum value max: 100, // maximum value + delayed: true, // delay search (set by filter_searchDelay) valueToHeader: false, // add current slider value to the header cell exactMatch: true, // exact (true) or match (false) allText: 'all', // text shown when the slider is at the minimum value @@ -157,6 +162,7 @@
  • The tooltip above the slider is added using pure css, which is included in the "filter.formatter.css" file, but it won't work in IE7 and older. But, you set the valueToHeader option to true to add the slider value to the header cell above the filter.
  • Another option named exactMatch was added to allow exact or general matching of column content.
  • Notice that the left-most value, zero in this case, will clear the column filter to allow a method to show all column content. You can modify the "all" text using the allText option.
  • +
  • A search delay was added in v2.7.11 (time set by filter_searchDelay option). It can be disabled by setting the delayed option to false.
  • @@ -187,6 +193,7 @@ values: [1, 70], // starting range min: 1, // minimum value max: 70, // maximum value + delayed: true, // delay search (set by filter_searchDelay) exactMatch: true, // exact (true) or match (false) valueToHeader: false // add current slider value to the header cell }); @@ -198,6 +205,7 @@ values: [1, 160], // starting range min: 1, // minimum value max: 160, // maximum value + delayed: true, // delay search (set by filter_searchDelay) exactMatch: true, // exact (true) or match (false) valueToHeader: false // add current slider value to the header cell }); @@ -210,6 +218,7 @@ });
  • The tooltip above the slider is added using pure css, which is included in the "filter.formatter.css" file, but it won't work in IE7 and older. But, you set the valueToHeader option to true to add the slider value to the header cell above the filter.
  • Another option named exactMatch was added to allow exact or general matching of column content.
  • +
  • A search delay was added in v2.7.11 (time set by filter_searchDelay option). It can be disabled by setting the delayed option to false.
  • @@ -237,6 +246,7 @@ max : 45, value: 1, step: 1, + delayed: true, addToggle: true, exactMatch: true, numberFormat: "n" @@ -249,6 +259,7 @@ });
  • This is the only jQuery UI widget that includes a toggle button. The toggle button is added by default, but if you don't want it, set the addToggle option to false. Without the toggle button, the filter is always active.
  • Another option named exactMatch was added to allow exact or general matching of column content.
  • +
  • A search delay was added in v2.7.11 (time set by filter_searchDelay option). It can be disabled by setting the delayed option to false.
  • @@ -320,6 +331,10 @@
    $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
  • Since, by default, the filter only matches cell content, a 1 in the filter will show all rows with a one no matter where it is located. So, if you need an exact match, add an equal sign to the end of the value (1=). This forces the filter to exactly match the value in the search input.
  • +
  • To include a search delay, trigger the search on the hidden input and pass a boolean. If true or undefined, the search will be delayed and not delayed if false. Delay time set by filter_searchDelay option). +
    $input.val( newVal ).trigger('search', false); // no search delay
    +
  • + diff --git a/docs/example-widget-filter-formatter-2.html b/docs/example-widget-filter-formatter-2.html index 6557da52..b293f1cc 100644 --- a/docs/example-widget-filter-formatter-2.html +++ b/docs/example-widget-filter-formatter-2.html @@ -47,6 +47,7 @@ value: 0, min: 0, max: 100, + delayed: true, valueToHeader: true }); }, @@ -62,6 +63,7 @@ value: 1, min: 1, max: 65, + delayed: true, addToggle: true, exactMatch: true }); @@ -119,6 +121,7 @@ value: 0, min: 0, max: 100, + delayed: true, valueToHeader: true, exactMatch: true, allText: 'all' @@ -133,6 +136,7 @@
  • The tooltip above the slider is NOT added in this example because the slider handle is not a separate element. But if you are interested, you can use this code by Chris Coyier to animate a range slider bubble.
  • Another option named exactMatch was added to allow exact or general matching of column content.
  • Notice that the left-most value, zero in this case, will clear the column filter to allow a method to show all column content. You can modify the "all" text using the allText option.
  • +
  • A search delay option was added in v2.7.11 (time set by filter_searchDelay option). It can be disabled by setting the delayed option to false.
  • @@ -195,6 +199,7 @@ value: 1, min: 1, max: 65, + delayed: true, addToggle: true, exactMatch: true }); @@ -206,6 +211,7 @@ });
  • This is spinner includes a toggle button. The toggle button is added by default, but if you don't want it, set the addToggle option to false. Without the toggle button, the filter is always active.
  • Another option named exactMatch was added to allow exact or general matching of column content.
  • +
  • A search delay option was added in v2.7.11 (time set by filter_searchDelay option). It can be disabled by setting the delayed option to false.
  • diff --git a/js/jquery.tablesorter.widgets-filter-formatter.js b/js/jquery.tablesorter.widgets-filter-formatter.js index 16329245..355a2e0d 100644 --- a/js/jquery.tablesorter.widgets-filter-formatter.js +++ b/js/jquery.tablesorter.widgets-filter-formatter.js @@ -1,4 +1,4 @@ -/*! Filter widget formatter functions - updated 2/17/2013 +/*! Filter widget formatter functions - updated 2/24/2013 * requires: tableSorter 2.7.7+ and jQuery 1.4.3+ * * jQuery UI spinner @@ -26,6 +26,7 @@ $.tablesorter.filterFormatter = { max : 100, step: 1, value: 1, + delayed: true, addToggle: true, disabled: false, exactMatch: true, @@ -44,7 +45,7 @@ $.tablesorter.filterFormatter = { } $cell.find('.filter') .val( chkd ? v + (o.exactMatch ? '=' : '') : '' ) // add equal to the end, so we filter exact numbers - .trigger('search').end() + .trigger('search', o.delayed).end() .find('#spinner' + indx).spinner( o.disabled || !chkd ? 'disable' : 'enable' ); }; @@ -99,6 +100,7 @@ $.tablesorter.filterFormatter = { max: 100, step: 1, range: "min", + delayed: true, valueToHeader : false, exactMatch: true, allText: 'all' @@ -120,7 +122,7 @@ $.tablesorter.filterFormatter = { // update the hidden input; // ****** ADD AN EQUAL SIGN TO THE END! <- this makes the slide exactly match the number ****** // when the value is at the minimum, clear the hidden input so all rows will be seen - $cell.find('.filter').val(v === o.min ? '' : v + (o.exactMatch ? '=' : '')).trigger('search'); + $cell.find('.filter').val(v === o.min ? '' : v + (o.exactMatch ? '=' : '')).trigger('search', o.delayed); }; $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed'); @@ -163,6 +165,7 @@ $.tablesorter.filterFormatter = { min : 0, max : 100, range: true, + delayed: true, valueToHeader : false }, rangeDef ), // Add a hidden input to hold the range values @@ -184,7 +187,7 @@ $.tablesorter.filterFormatter = { .eq(1).attr('data-value', val[1]); // value popup shown via css } // update the hidden input - $cell.find('.filter').val(range).trigger('search'); + $cell.find('.filter').val(range).trigger('search', o.delayed); }; $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed'); @@ -286,6 +289,7 @@ $.tablesorter.filterFormatter = { min: 0, max: 100, step: 1, + delayed: true, disabled: false, addToggle: true, exactMatch: true @@ -296,13 +300,11 @@ $.tablesorter.filterFormatter = { // test if HTML5 number is supported - from Modernizr numberSupported = $number.attr('type') === 'number' && $number.val() !== 'test', updateNumber = function(){ - var chkd = true, val = $cell.find('.number').val(); - if (o.addToggle) { - chkd = $cell.find('.toggle').is(':checked'); - } + var val = $cell.find('.number').val(), + chkd = o.addToggle ? $cell.find('.toggle').is(':checked') : true; $cell .find('input[type=hidden]').val( chkd ? val + (o.exactMatch ? '=' : '') : '' ) // add equal to the end, so we filter exact numbers - .trigger('search'); + .trigger('search', o.delayed); if ($cell.find('.number').length) { $cell.find('.number')[0].disabled = (o.disabled || !chkd); } @@ -342,6 +344,7 @@ $.tablesorter.filterFormatter = { min: 0, max: 100, step: 1, + delayed: true, valueToHeader: true, exactMatch: true, allText: 'all' @@ -357,7 +360,7 @@ $.tablesorter.filterFormatter = { var val = $cell.find('.range').val(); $cell .find('input[type=hidden]').val( val == o.min ? '' : val + (o.exactMatch ? '=' : '')) // add equal to the end, so we filter exact numbers - .trigger('search'); + .trigger('search', o.delayed); // or add current color to the header cell, if desired $cell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + (val == o.min ? o.allText : val) + ')'); }; diff --git a/js/jquery.tablesorter.widgets-filter-formatter.min.js b/js/jquery.tablesorter.widgets-filter-formatter.min.js index b91a2672..d93542c0 100644 --- a/js/jquery.tablesorter.widgets-filter-formatter.min.js +++ b/js/jquery.tablesorter.widgets-filter-formatter.min.js @@ -1,6 +1,6 @@ -/*! Filter widget formatter functions - updated 2/17/2013 +/*! Filter widget formatter functions - updated 2/24/2013 * requires: tableSorter 2.7.7+ and jQuery 1.4.3+ * jQuery UI spinner, silder, range slider & datepicker (range) * HTML5 number (spinner), range slider & color selector */ -;(function(f){f.tablesorter=f.tablesorter||{};f.tablesorter.filterFormatter={uiSpinner:function(b,e,d){var a=f.extend({min:0,max:100,step:1,value:1,addToggle:!0,disabled:!1,exactMatch:!0,numberFormat:"n"},d);d=f('').appendTo(b);var c=function(g){var c=!0;g=g&&g.value||f("#spinner"+e).val()||a.value;a.addToggle&&(c=b.find(".toggle").is(":checked"));b.find(".filter").val(c?g+(a.exactMatch?"=":""):"").trigger("search").end().find("#spinner"+e).spinner(a.disabled||!c? "disable":"enable")};a.oldcreate=a.create;a.oldspin=a.spin;a.create=function(b,h){c();"function"===typeof a.oldcreate&&a.oldcreate(b,h)};a.spin=function(b,h){c(h);"function"===typeof a.oldspin&&a.oldspin(b,h)};a.addToggle&&f('
    ').appendTo(b).find(".toggle").bind("change",function(){c()});b.closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed");f('').val(a.value).appendTo(b).spinner(a).bind("change keyup",function(){c()});b.closest("table").bind("filterReset",function(){b.find(".toggle")[0].checked=!1;c()});c();return d},uiSlider:function(b,e,d){var a=f.extend({value:0,min:0,max:100,step:1,range:"min",valueToHeader:!1,exactMatch:!0,allText:"all"},d);d=f('').appendTo(b);var c=function(g){g="undefined"!==typeof g?g.value:a.value;a.valueToHeader?b.closest("thead").find("th[data-column="+e+"]").find(".curvalue").html(" ("+ (g===a.min?a.allText:g)+")"):b.find(".ui-slider-handle").addClass("value-popup").attr("data-value",g===a.min?a.allText:g);b.find(".filter").val(g===a.min?"":g+(a.exactMatch?"=":"")).trigger("search")};b.closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed");a.valueToHeader&&b.closest("thead").find("th[data-column="+e+"]").find(".tablesorter-header-inner").append('');a.oldcreate=a.create;a.oldslide=a.slide;a.create=function(b,h){c();"function"===typeof a.oldcreate&& a.oldcreate(b,h)};a.slide=function(b,h){c(h);"function"===typeof a.oldslide&&a.oldslide(b,h)};f('
    ').appendTo(b).slider(a);b.closest("table").bind("filterReset",function(){b.find('div[id*="slider"]').slider("value",a.value);c()});return d},uiRange:function(b,e,d){var a=f.extend({values:[0,100],min:0,max:100,range:!0,valueToHeader:!1},d);d=f('').appendTo(b);var c=function(c){c="undefined"!==typeof c&&c.values||a.values;var h=c[0]+" - "+c[1]; a.valueToHeader?b.closest("thead").find("th[data-column="+e+"]").find(".currange").html(" ("+h+")"):b.find(".ui-slider-handle").addClass("value-popup").eq(0).attr("data-value",c[0]).end().eq(1).attr("data-value",c[1]);b.find(".filter").val(h).trigger("search")};b.closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed");a.valueToHeader&&b.closest("thead").find("th[data-column="+e+"]").find(".tablesorter-header-inner").append('');a.oldcreate=a.create;a.oldslide= a.slide;a.create=function(b,h){c();"function"===typeof a.oldcreate&&a.oldcreate(b,h)};a.slide=function(b,h){c(h);"function"===typeof a.oldslide&&a.oldslide(b,h)};f('
    ').appendTo(b).slider(a);b.closest("table").bind("filterReset",function(){b.find('div[id*="range"]').slider("values",a.values);c()});return d},uiDatepicker:function(b,e,d){var a=f.extend({from:"",to:"",changeMonth:!0,changeYear:!0,numberOfMonths:1},d);d=f('').appendTo(b);b.closest("thead").find("th[data-column="+ e+"]").addClass("filter-parsed");f('').appendTo(b);a.oldonClose=a.onClose;a.defaultDate=a.defaultDate||a.from;a.onClose=function(c,d){var h=(new Date(c)).getTime()||"",e=(new Date(b.find(".dateTo").val())).getTime()||"";b.find(".dateTo").datepicker("option","minDate",c).end().find(".dateRange").val(h&&e?h+" - "+e:"").trigger("search");"function"===typeof a.oldonClose&&a.oldonClose(c,d)};b.find(".dateFrom").datepicker(a); a.defaultDate=a.defaultDate||a.to;a.onClose=function(c,e){var h=(new Date(b.find(".dateFrom").val())).getTime()||"",d=(new Date(c)).getTime()||"";b.find(".dateFrom").datepicker("option","maxDate",c).end().find(".dateRange").val(h&&d?h+" - "+d:"").trigger("search");"function"===typeof a.oldonClose&&a.oldonClose(c,e)};b.find(".dateTo").datepicker(a);b.closest("table").bind("filterReset",function(){b.find(".dateFrom, .dateTo").val("").datepicker("option","currentText","")});return d},html5Number:function(b, e,d){var a,c=f.extend({value:0,min:0,max:100,step:1,disabled:!1,addToggle:!0,exactMatch:!0},d);a=f('').appendTo(b);d="number"===a.attr("type")&&"test"!==a.val();var g=function(){var a=!0,d=b.find(".number").val();c.addToggle&&(a=b.find(".toggle").is(":checked"));b.find("input[type=hidden]").val(a?d+(c.exactMatch?"=":""):"").trigger("search");b.find(".number").length&&(b.find(".number")[0].disabled=c.disabled||!a)};a.remove();d&&(a=c.addToggle? '
    ':"",a+='',b.html(a).find(".toggle, .number").bind("change",function(){g()}).closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed").closest("table").bind("filterReset",function(){b.find(".toggle")[0].checked=!1;g()}));g();return d?b.find('input[type="hidden"]'): f('')},html5Range:function(b,e,d){var a=f.extend({value:0,min:0,max:100,step:1,valueToHeader:!0,exactMatch:!0,allText:"all"},d);d=f('').appendTo(b);var c="range"===d.attr("type")&&"test"!==d.val(),g=function(){var c=b.find(".range").val();b.find("input[type=hidden]").val(c==a.min?"":c+(a.exactMatch?"=":"")).trigger("search");b.closest("thead").find("th[data-column="+e+"]").find(".curvalue").html(" ("+(c==a.min?a.allText: c)+")")};d.remove();c&&(b.html('').closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed").find(".tablesorter-header-inner").append(''),b.find(".range").bind("change",function(){g()}),b.closest("table").bind("filterReset",function(){b.find("input.range").val(a.value);g()}));g();return c?b.find('input[type="hidden"]'):f('')},html5Color:function(b, e,d){var a,c=f.extend({value:"#000000",disabled:!1,addToggle:!0,valueToHeader:!1},d);a=f('').appendTo(b);d="color"===a.attr("type")&&"test"!==a.val();var g=function(){var a=!0,d=b.find(".colorpicker").val();c.addToggle&&(a=b.find(".toggle").is(":checked"));b.find(".colorpicker").length&&(b.find(".colorpicker")[0].disabled=c.disabled||!a);b.find("input[type=hidden]").val(a?d:"").trigger("search");c.valueToHeader?b.closest("thead").find("th[data-column="+ e+"]").find(".curcolor").html(" ("+d+")"):b.find(".currentColor").html(" ("+d+")")};a.remove();d&&(a=c.addToggle?'
    ':"",a=a+''+(c.valueToHeader?"":'(#000000)'),b.html(a),c.valueToHeader&&b.closest("thead").find("th[data-column="+e+"]").find(".tablesorter-header-inner").append(''), b.find(".toggle, .colorpicker").bind("change",function(){g()}),b.closest("table").bind("filterReset",function(){b.find(".toggle")[0].checked=!1;g()}));g();return d?b.find('input[type="hidden"]'):f('')}}})(jQuery); +;(function(f){f.tablesorter=f.tablesorter||{};f.tablesorter.filterFormatter={uiSpinner:function(b,e,d){var a=f.extend({min:0,max:100,step:1,value:1,delayed:!0,addToggle:!0,disabled:!1,exactMatch:!0,numberFormat:"n"},d);d=f('').appendTo(b);var c=function(h){var c=!0;h=h&&h.value||f("#spinner"+e).val()||a.value;a.addToggle&&(c=b.find(".toggle").is(":checked"));b.find(".filter").val(c?h+(a.exactMatch?"=":""):"").trigger("search",a.delayed).end().find("#spinner"+e).spinner(a.disabled|| !c?"disable":"enable")};a.oldcreate=a.create;a.oldspin=a.spin;a.create=function(b,g){c();"function"===typeof a.oldcreate&&a.oldcreate(b,g)};a.spin=function(b,g){c(g);"function"===typeof a.oldspin&&a.oldspin(b,g)};a.addToggle&&f('
    ').appendTo(b).find(".toggle").bind("change",function(){c()});b.closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed");f('').val(a.value).appendTo(b).spinner(a).bind("change keyup",function(){c()});b.closest("table").bind("filterReset",function(){b.find(".toggle")[0].checked=!1;c()});c();return d},uiSlider:function(b,e,d){var a=f.extend({value:0,min:0,max:100,step:1,range:"min",delayed:!0,valueToHeader:!1,exactMatch:!0,allText:"all"},d);d=f('').appendTo(b);var c=function(c){c="undefined"!==typeof c?c.value:a.value;a.valueToHeader?b.closest("thead").find("th[data-column="+e+ "]").find(".curvalue").html(" ("+(c===a.min?a.allText:c)+")"):b.find(".ui-slider-handle").addClass("value-popup").attr("data-value",c===a.min?a.allText:c);b.find(".filter").val(c===a.min?"":c+(a.exactMatch?"=":"")).trigger("search",a.delayed)};b.closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed");a.valueToHeader&&b.closest("thead").find("th[data-column="+e+"]").find(".tablesorter-header-inner").append('');a.oldcreate=a.create;a.oldslide=a.slide;a.create= function(b,g){c();"function"===typeof a.oldcreate&&a.oldcreate(b,g)};a.slide=function(b,g){c(g);"function"===typeof a.oldslide&&a.oldslide(b,g)};f('
    ').appendTo(b).slider(a);b.closest("table").bind("filterReset",function(){b.find('div[id*="slider"]').slider("value",a.value);c()});return d},uiRange:function(b,e,d){var a=f.extend({values:[0,100],min:0,max:100,range:!0,delayed:!0,valueToHeader:!1},d);d=f('').appendTo(b);var c=function(c){c="undefined"!== typeof c&&c.values||a.values;var g=c[0]+" - "+c[1];a.valueToHeader?b.closest("thead").find("th[data-column="+e+"]").find(".currange").html(" ("+g+")"):b.find(".ui-slider-handle").addClass("value-popup").eq(0).attr("data-value",c[0]).end().eq(1).attr("data-value",c[1]);b.find(".filter").val(g).trigger("search",a.delayed)};b.closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed");a.valueToHeader&&b.closest("thead").find("th[data-column="+e+"]").find(".tablesorter-header-inner").append(''); a.oldcreate=a.create;a.oldslide=a.slide;a.create=function(b,g){c();"function"===typeof a.oldcreate&&a.oldcreate(b,g)};a.slide=function(b,g){c(g);"function"===typeof a.oldslide&&a.oldslide(b,g)};f('
    ').appendTo(b).slider(a);b.closest("table").bind("filterReset",function(){b.find('div[id*="range"]').slider("values",a.values);c()});return d},uiDatepicker:function(b,e,d){var a=f.extend({from:"",to:"",changeMonth:!0,changeYear:!0,numberOfMonths:1},d);d=f('').appendTo(b); b.closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed");f('').appendTo(b);a.oldonClose=a.onClose;a.defaultDate=a.defaultDate||a.from;a.onClose=function(c,d){var g=(new Date(c)).getTime()||"",e=(new Date(b.find(".dateTo").val())).getTime()||"";b.find(".dateTo").datepicker("option","minDate",c).end().find(".dateRange").val(g&&e?g+" - "+e:"").trigger("search");"function"=== typeof a.oldonClose&&a.oldonClose(c,d)};b.find(".dateFrom").datepicker(a);a.defaultDate=a.defaultDate||a.to;a.onClose=function(c,e){var g=(new Date(b.find(".dateFrom").val())).getTime()||"",d=(new Date(c)).getTime()||"";b.find(".dateFrom").datepicker("option","maxDate",c).end().find(".dateRange").val(g&&d?g+" - "+d:"").trigger("search");"function"===typeof a.oldonClose&&a.oldonClose(c,e)};b.find(".dateTo").datepicker(a);b.closest("table").bind("filterReset",function(){b.find(".dateFrom, .dateTo").val("").datepicker("option", "currentText","")});return d},html5Number:function(b,e,d){var a,c=f.extend({value:0,min:0,max:100,step:1,delayed:!0,disabled:!1,addToggle:!0,exactMatch:!0},d);a=f('').appendTo(b);d="number"===a.attr("type")&&"test"!==a.val();var h=function(){var a=b.find(".number").val(),d=c.addToggle?b.find(".toggle").is(":checked"):!0;b.find("input[type=hidden]").val(d?a+(c.exactMatch?"=":""):"").trigger("search",c.delayed);b.find(".number").length&&(b.find(".number")[0].disabled= c.disabled||!d)};a.remove();d&&(a=c.addToggle?'
    ':"",a+='',b.html(a).find(".toggle, .number").bind("change",function(){h()}).closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed").closest("table").bind("filterReset",function(){b.find(".toggle")[0].checked= !1;h()}));h();return d?b.find('input[type="hidden"]'):f('')},html5Range:function(b,e,d){var a=f.extend({value:0,min:0,max:100,step:1,delayed:!0,valueToHeader:!0,exactMatch:!0,allText:"all"},d);d=f('').appendTo(b);var c="range"===d.attr("type")&&"test"!==d.val(),h=function(){var c=b.find(".range").val();b.find("input[type=hidden]").val(c==a.min?"":c+(a.exactMatch?"=":"")).trigger("search",a.delayed);b.closest("thead").find("th[data-column="+ e+"]").find(".curvalue").html(" ("+(c==a.min?a.allText:c)+")")};d.remove();c&&(b.html('').closest("thead").find("th[data-column="+e+"]").addClass("filter-parsed").find(".tablesorter-header-inner").append(''),b.find(".range").bind("change",function(){h()}),b.closest("table").bind("filterReset",function(){b.find("input.range").val(a.value);h()}));h();return c?b.find('input[type="hidden"]'): f('')},html5Color:function(b,e,d){var a,c=f.extend({value:"#000000",disabled:!1,addToggle:!0,valueToHeader:!1},d);a=f('').appendTo(b);d="color"===a.attr("type")&&"test"!==a.val();var h=function(){var a=!0,d=b.find(".colorpicker").val();c.addToggle&&(a=b.find(".toggle").is(":checked"));b.find(".colorpicker").length&&(b.find(".colorpicker")[0].disabled=c.disabled||!a);b.find("input[type=hidden]").val(a?d:"").trigger("search"); c.valueToHeader?b.closest("thead").find("th[data-column="+e+"]").find(".curcolor").html(" ("+d+")"):b.find(".currentColor").html(" ("+d+")")};a.remove();d&&(a=c.addToggle?'
    ':"",a=a+''+(c.valueToHeader?"":'(#000000)'),b.html(a),c.valueToHeader&&b.closest("thead").find("th[data-column="+e+ "]").find(".tablesorter-header-inner").append(''),b.find(".toggle, .colorpicker").bind("change",function(){h()}),b.closest("table").bind("filterReset",function(){b.find(".toggle")[0].checked=!1;h()}));h();return d?b.find('input[type="hidden"]'):f('')}}})(jQuery); diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index 8bc04979..17c47b12 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -410,7 +410,7 @@ $.tablesorter.addWidget({ } // Look for quotes or equals to get an exact match; ignore type since xi could be numeric /*jshint eqeqeq:false */ - } else if (reg.exact.test(val) && xi == val.replace(reg.exact, '')){ + } else if (val.replace(reg.exact, '') == xi){ ff = true; // Look for a not match } else if (/^\!/.test(val)){ @@ -576,22 +576,23 @@ $.tablesorter.addWidget({ if (e.type === 'filterReset') { $t.find('.' + css).val(''); } - checkFilters(e.type === 'search' ? filter : ''); + // send false argument to force a new search; otherwise if the filter hasn't changed, it will return + checkFilters(e.type === 'search' ? filter : false); return false; }) .find('input.' + css).bind('keyup search', function(e, filter){ // ignore arrow and meta keys; allow backspace - if ((e.which < 32 && e.which !== 8) || (e.which >= 37 && e.which <=40)) { return; } + if (e.type === 'keyup' && ((e.which < 32 && e.which !== 8) || (e.which >= 37 && e.which <=40))) { return; } // skip delay - if (typeof filter !== 'undefined'){ + if (typeof filter !== 'undefined' && filter !== true){ checkFilters(filter); - return false; } // delay filtering clearTimeout(timer); timer = setTimeout(function(){ - checkFilters(); + checkFilters(false); }, wo.filter_searchDelay || 300); + return false; }); // parse columns after formatter, in case the class is added at that point