diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/views/request/new.html.erb | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb index f6194fb41..178ef7638 100644 --- a/app/views/request/new.html.erb +++ b/app/views/request/new.html.erb @@ -5,18 +5,27 @@ // debounce jQuery plugin: // http://benalman.com/projects/jquery-throttle-debounce-plugin/ $("#typeahead_search").keypress($.debounce( 300, function() { + if ( $('#request_search_ahead_results').text().trim().length > 0) { + $('#typeahead_response').slideUp('fast'); + } + $("#typeahead_response").load("<%= search_ahead_url %>?q="+encodeURI(this.value)+ "&requested_from=<%= @info_request.public_body.url_name %>"+ "&per_page=3", function() { - // When following links in typeahead results, open new - // tab/window - $("#typeahead_response a").attr("target","_blank"); - - // Update the public body site search link - $("#body-site-search-link").attr("href", "http://www.google.com/#q="+encodeURI($("#typeahead_search").val())+ - "+site:<%= @info_request.public_body.calculated_home_page %>"); - $('.close-button').click(function() { $(this).parent().hide() }); + if ( $('#request_search_ahead_results').text().trim().length > 0) { + $('#typeahead_response').hide().slideDown('fast'); + + // When following links in typeahead results, open new + // tab/window + $("#typeahead_response a").attr("target","_blank"); + + // Update the public body site search link + $("#body-site-search-link").attr("href", "http://www.google.com/#q="+encodeURI($("#typeahead_search").val())+ + "+site:<%= @info_request.public_body.calculated_home_page %>"); + + $('.close-button').click(function() { $(this).parent().hide() }); + } }); })); }); |