1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<script type="text/javascript" src="/javascripts/ba-throttle-debounce.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#authority_preview").hide();
// Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin:
// http://benalman.com/projects/jquery-throttle-debounce-plugin/
$("#query").keypress($.debounce( 300, function() {
// Do a type ahead search and display results
$("#typeahead_response").load("<%=search_ahead_bodies_url%>?query="+encodeURI(this.value), function() {
$("#authority_preview").hide(); // Hide the preview, since results have changed
});
}));
// We're using the existing body list: we intercept the clicks on the titles to
// display a preview on the right hand side of the screen
$("#typeahead_response .head a").live('click', function() {
$("#authority_preview").load(this.href+" #public_body_show", function() {
$("#authority_preview").show();
$(window).scrollTop($("#banner").height());
$("#authority_preview #header_right").hide();
});
return false;
});
});
</script>
<% @title = _("Select the authority to write to") %>
<h1 style="clear: left"><%= _('1. Select an authority') %></h1>
<div id="authority_selection">
<% form_tag({:controller => "request", :action => "select_authority"}, {:id => "search_form", :method => "get"}) do %>
<p>
<p>
<%= _('First, type in the <strong>name of the UK public authority</strong> you\'d
like information from. <strong>By law, they have to respond</strong>
(<a href="%s#%s">why?</a>).') % [help_about_url, "whybother_them"] %>
</p>
<%= text_field_tag 'query', params[:query], { :size => 30 } %>
<%= hidden_field_tag 'bodies', 1 %>
<%= submit_tag _('Search') %>
</p>
<% end %>
<div id="typeahead_response">
<% if !@xapian_requests.nil? %>
<% if @xapian_requests.results.size > 0 %>
<h3><%= _('Top search results:') %></h3>
<p>
<%= _('Select one to see more information about the authority.')%>
</p>
<% else %>
<h3><%= _('No results found.') %></h3>
<% end %>
<div id="authority_search_ahead_results">
<% for result in @xapian_requests.results %>
<%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %>
<% end %>
</div>
<% end %>
</div>
</div>
<div id="authority_preview">
</div>
|