From fd8288364a41b2f9390cc3bf2ec14f17d298d842 Mon Sep 17 00:00:00 2001 From: Victor Suhov Date: Mon, 18 Sep 2017 23:47:58 +0300 Subject: [PATCH] add handling for multiple search values --- src/configuration.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/configuration.js b/src/configuration.js index aa734d2..1e2f717 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -53,12 +53,24 @@ var EasyAutocomplete = (function(scope){ enabled: false, caseSensitive: false, method: function(element, phrase) { + let phraseSplitted = phrase.split( ' ' ) + , matchFlagAcc = []; + + for( var i = 0; i < phraseSplitted.length; ++i ) { + if ( ~element.indexOf( phraseSplitted[ i ] ) ) { + matchFlagAcc.push( true ); + } else { + matchFlagAcc.push( false ); + } + } - if (element.search(phrase) > -1) { - return true; - } else { - return false; + for( var i = 0; i < matchFlagAcc.length; ++i ) { + if ( !matchFlagAcc[ i ] ) { + return false; + } } + + return true; } },