From 9c0eaac6b85862a0377520a823b95643dd59dc16 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 14 Mar 2016 10:25:08 +0200 Subject: [PATCH] Enable entering search text before results are loaded --- resources/views/header.blade.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 09525079e3..4a795e0e8a 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -258,18 +258,16 @@ localStorage.setItem('auth_provider', provider); } + window.loadedSearchData = false; function showSearch() { $('#search').typeahead('val', ''); $('#navbar-options').hide(); $('#search-form').show(); - - if (window.hasOwnProperty('loadedSearchData')) { - $('#search').focus(); - } else { + $('#search').focus(); + + if (!window.loadedSearchData) { trackEvent('/activity', '/search'); $.get('{{ URL::route('getSearchData') }}', function(data) { - window.loadedSearchData = true; - $('#search').typeahead({ hint: true, highlight: true, @@ -307,6 +305,7 @@ ).on('typeahead:selected', function(element, datum, name) { window.location = datum.url; }).focus(); + window.loadedSearchData = true; }); } } @@ -322,7 +321,9 @@ }, 3000); $('#search').blur(function(event){ - hideSearch(); + if (window.loadedSearchData) { + hideSearch(); + } }); if (isStorageSupported()) {