Don't autofocus search, fade out "Where am I?" on focus
authorJohn Firebaugh <john.firebaugh@gmail.com>
Wed, 2 Oct 2013 18:22:56 +0000 (11:22 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Sun, 13 Oct 2013 21:46:06 +0000 (14:46 -0700)
app/assets/javascripts/index/search.js
app/views/layouts/map.html.erb

index ce00fa0afff8c74600f757be2732e80288936253..c546469db941a258ee72694481872f546d30b028 100644 (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);
 
index 55953f004e510269fb474a34b414c21f6d9caf6b..7019224861b69bf76006196dec15971b663d7bdd 100644 (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') } %>