From d3bf4149e09053436d8d266952c49bb8f7ef6946 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 2 Oct 2013 11:22:56 -0700 Subject: [PATCH] Don't autofocus search, fade out "Where am I?" on focus --- app/assets/javascripts/index/search.js | 12 +++++++----- app/views/layouts/map.html.erb | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index ce00fa0af..c546469db 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -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); diff --git a/app/views/layouts/map.html.erb b/app/views/layouts/map.html.erb index 55953f004..701922486 100644 --- a/app/views/layouts/map.html.erb +++ b/app/views/layouts/map.html.erb @@ -8,8 +8,7 @@ <%= submit_tag t('site.search.submit_text') %>
<%= 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') } %> -- 2.43.2