Don't autofocus search, fade out "Where am I?" on focus

This commit is contained in:
John Firebaugh 2013-10-02 11:22:56 -07:00
parent ad7bc7415b
commit d3bf4149e0
2 changed files with 8 additions and 7 deletions

View file

@ -6,11 +6,13 @@ function initializeSearch(map) {
$("#search_form").submit();
}
// Focus the search field for browsers that don't support
// the HTML5 'autofocus' attribute
if (!("autofocus" in document.createElement("input"))) {
$("#query").focus();
}
$("#query")
.on("focus", function() {
$("#describe_location").fadeOut(100);
})
.on("blur", function() {
$("#describe_location").fadeIn(100);
});
$("#sidebar_content").on("click", ".search_results_entry a.set_position", clickSearchResult);

View file

@ -8,8 +8,7 @@
<%= submit_tag t('site.search.submit_text') %>
<div id='query_wrapper'>
<%= text_field_tag :query, params[:query],
:placeholder => t('site.search.search'),
:autofocus => "autofocus" %>
:placeholder => t('site.search.search') %>
<%= link_to t('site.search.where_am_i'),
{ :controller => :geocoder, :action => :description },
{ :id => "describe_location", :title => t('site.search.where_am_i_title') } %>