From fa2a11c7745ca130f9dfa33bb548c07bc0468526 Mon Sep 17 00:00:00 2001 From: Mottie Date: Fri, 26 Apr 2013 17:41:39 -0500 Subject: [PATCH] filter_liveSearch can now contain a minimum number of characters; see #286 --- js/jquery.tablesorter.widgets.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index cb4d586d..c0fe8bc8 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -582,8 +582,14 @@ ts.addWidget({ return false; }) .find('input.' + css).bind('keyup search', function(e, filter){ - // ignore arrow and meta keys; allow backspace - if (e.type === 'keyup' && ((e.which < 32 && e.which !== 8 && wo.filter_liveSearch && e.which !== 13) || (e.which >= 37 && e.which <=40) || (e.which !== 13 && !wo.filter_liveSearch))) { return; } + // emulate what webkit does.... escape clears the filter + if (e.which === 27) { + this.value = ''; + // liveSearch can contain a min value length; ignore arrow and meta keys, but allow backspace + } else if ( (typeof wo.filter_liveSearch === 'number' && this.value.length < wo.filter_liveSearch && this.value !== '') || ( e.type === 'keyup' && + ( (e.which < 32 && e.which !== 8 && wo.filter_liveSearch === true && e.which !== 13) || (e.which >= 37 && e.which <=40) || (e.which !== 13 && wo.filter_liveSearch === false) ) ) ) { + return; + } // skip delay if (typeof filter !== 'undefined' || filter === false){ checkFilters();