Restore autofocusing of the search field

Use the HTML5 autofocus attribute, and focus on load for browsers
which don't support it.

Also change the removal of the "Where am I?" prompt to happen on
input rather than when the field is focused, so that it is properly
removed and restored when the field has been autofocused.

Fixes https://trac.openstreetmap.org/ticket/5065
This commit is contained in:
Tom Hughes 2013-12-10 19:45:28 +00:00
parent c2c817ad1f
commit 9cc9a00988
3 changed files with 11 additions and 6 deletions

View file

@ -1,7 +1,7 @@
<%= form_tag search_path, :class => "search_form" do %>
<%= submit_tag t('site.search.submit_text') %>
<div class='query_wrapper'>
<input type="text" name="query" value="<%= params[:query] %>" placeholder="<%= t('site.search.search') %>">
<input type="text" name="query" value="<%= params[:query] %>" placeholder="<%= t('site.search.search') %>" autofocus>
<%= link_to t('site.search.where_am_i'), '#', { :class => "describe_location", :title => t('site.search.where_am_i_title') } %>
</div>
<% end %>