]> git.openstreetmap.org Git - rails.git/commitdiff
Move search form to header on small screens
authorJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 11 Nov 2013 21:37:32 +0000 (13:37 -0800)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 11 Nov 2013 21:38:46 +0000 (13:38 -0800)
app/assets/javascripts/index.js
app/assets/javascripts/index/search.js
app/assets/stylesheets/common.css.scss
app/assets/stylesheets/small.css.scss
app/views/layouts/_header.html.erb
app/views/layouts/_search.html.erb [new file with mode: 0644]
app/views/layouts/map.html.erb

index 5e96c35174a6f66fb106b58c7ffe6fb234689e48..7d2e954ad4528d72405a0b504970b5de69e826be 100644 (file)
@@ -297,12 +297,13 @@ $(document).ready(function () {
     if (this.host === window.location.host && OSM.route(this.pathname + this.search + this.hash)) e.preventDefault();
   });
 
-  $("#search_form").on("submit", function(e) {
+  $(".search_form").on("submit", function(e) {
     e.preventDefault();
-    OSM.route("/search?query=" + encodeURIComponent($("#query").val()) + OSM.formatHash(map));
+    $("header").addClass("closed");
+    OSM.route("/search?query=" + encodeURIComponent($(this).find("input[name=query]").val()) + OSM.formatHash(map));
   });
 
-  $("#describe_location").on("click", function(e) {
+  $(".describe_location").on("click", function(e) {
     e.preventDefault();
     var precision = zoomPrecision(map.getZoom());
     OSM.route("/search?query=" + encodeURIComponent(
index e92f3747f0b39e1c472d339a0db5fe725780cec7..7f6eac9ca723a3a3b62e262539d96b5d1d741bb8 100644 (file)
@@ -1,10 +1,10 @@
 OSM.Search = function(map) {
-  $("#query")
+  $(".search_form input[name=query]")
     .on("focus", function() {
-      $("#describe_location").fadeOut(100);
+      $(".describe_location").fadeOut(100);
     })
     .on("blur", function() {
-      $("#describe_location").fadeIn(100);
+      $(".describe_location").fadeIn(100);
     });
 
   $("#sidebar_content")
@@ -48,7 +48,8 @@ OSM.Search = function(map) {
 
   page.pushstate = page.popstate = function(path) {
     var params = querystring.parse(path.substring(path.indexOf('?') + 1));
-    $("#query").val(params.query);
+    $(".search_form input[name=query]").val(params.query);
+    map.invalidateSize();
     $("#sidebar_content").load(path, function() {
       if (xhr.getResponseHeader('X-Page-Title')) {
         document.title = xhr.getResponseHeader('X-Page-Title');
@@ -80,7 +81,7 @@ OSM.Search = function(map) {
   page.unload = function() {
     map.removeLayer(marker);
     map.removeObject();
-    $("#query").val("");
+    $(".search_form input[name=query]").val("");
   };
 
   return page;
index 081f0945f300bca5460f00cf0dac2668d3b82c83..86b5a6a757d2b0b3f593768c722eea684ad3de5a 100644 (file)
@@ -900,21 +900,25 @@ nav.secondary {
 
 /* Rules for the search box */
 
-#search_form {
+header .search_form {
+  display: none;
+}
+
+.search_form {
   position: relative;
   padding: $lineheight/2;
   background-color: $lightgrey;
 
-  #query_wrapper {
+  .query_wrapper {
     position: relative;
     overflow: hidden;
+    border-radius: 2px 0 0 2px;
   }
 
-  input {
+  input[type=text] {
     width: 100%;
     height: 30px;
     border-right: none;
-    border-radius: 2px 0 0 2px;
 
     transition: 300ms linear;
     -webkit-transition: 300ms linear;
@@ -933,7 +937,7 @@ nav.secondary {
     border-radius: 0 2px 2px 0;
   }
 
-  #describe_location {
+  .describe_location {
     position: absolute;
     top: 6px;
     right: 6px;
index 182272e780da3db10c05f4237d80a02847e36ed0..5e8edc28c78988ce4856172e080af8a86d3397ac 100644 (file)
@@ -32,8 +32,13 @@ header {
   &.closed nav {
     display: none;
   }
+
+  .search_form {
+    display: block;
+  }
 }
 
+#sidebar .search_form,
 #edit_tab,
 #export_tab {
   display: none;
index 1142eeb79c055c49b36985320118da768ade9bb5..334056ee181cfe5cc8d8d9b1c46a554653c45f35 100644 (file)
@@ -7,6 +7,7 @@
   </h1>
   <a href="#" id="menu-icon"></a>
   <nav class='primary'>
+    <%= render :partial => "layouts/search" %>
     <ul>
       <li id="edit_tab" class="dropdown <%= current_page_class(edit_path) %>">
         <%= link_to t('layouts.edit'), edit_path, :class => "tab geolink editlink",
diff --git a/app/views/layouts/_search.html.erb b/app/views/layouts/_search.html.erb
new file mode 100644 (file)
index 0000000..1d054d5
--- /dev/null
@@ -0,0 +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') %>">
+    <%= link_to t('site.search.where_am_i'), '#', { :class => "describe_location", :title => t('site.search.where_am_i_title') } %>
+  </div>
+<% end %>
index 1daae059ec517b19d70b6752411f521dbdf720ee..a7d00f53fb4e85852e7c63c2ad42071577523225 100644 (file)
 
 <% content_for :content do %>
   <div id="sidebar">
-    <%= form_tag search_path, :id => "search_form" do %>
-      <%= submit_tag t('site.search.submit_text') %>
-      <div id='query_wrapper'>
-        <%= text_field_tag :query, params[:query],
-                           :placeholder => t('site.search.search') %>
-        <%= link_to t('site.search.where_am_i'), '#', { :id => "describe_location", :title => t('site.search.where_am_i_title') } %>
-      </div>
-    <% end %>
+    <%= render :partial => "layouts/search" %>
 
     <% if STATUS == :database_offline or STATUS == :api_offline %>
       <p class="error"><%= t 'layouts.osm_offline' %></p>