From df46fa25876839ca768551a674c0da74b81d1a89 Mon Sep 17 00:00:00 2001 From: benjaminneildavis Date: Mon, 5 Jan 2015 15:05:18 -0500 Subject: [PATCH] Fix of search when tabbing in --- js/search.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/js/search.js b/js/search.js index fb045608b..7107d5317 100644 --- a/js/search.js +++ b/js/search.js @@ -111,12 +111,21 @@ if (e.which === 13) { e.preventDefault(); this.action(); - } else { + } + else if (e.which === 9) { + e.preventDefault(); + } + else { val = this.$input.val(); - if(!val){ - this.clear(); - }else if(val!==this.activeSearch){ + + if(val!==this.activeSearch){ this.$icon.removeClass(remove).addClass(search); + if(val) { + this.$element.removeClass('searched'); + } + else if (this.options.clearOnEmpty){ + this.clear(); + } }else{ this.$icon.removeClass(search).addClass(remove); } @@ -156,7 +165,9 @@ return ( methodReturn === undefined ) ? $set : methodReturn; }; - $.fn.search.defaults = {}; + $.fn.search.defaults = { + clearOnEmpty: false + }; $.fn.search.Constructor = Search;