From 322e6403bb0ccb4011f5b8e34a9b55b425df5f94 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Fri, 25 Feb 2011 16:34:01 -0500 Subject: [PATCH] Zoom after search --- app/controllers/welcome_controller.rb | 10 +++++ app/views/layouts/application.html.erb | 13 +++++- app/views/welcome/index.html.erb | 36 ++++++----------- config/routes.rb | 56 +------------------------- public/javascripts/maps.js | 12 ------ public/stylesheets/main.css | 5 +-- 6 files changed, 38 insertions(+), 94 deletions(-) delete mode 100644 public/javascripts/maps.js diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index d8c85ab..eb2fb10 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -1,2 +1,12 @@ class WelcomeController < ApplicationController + def index + # Default coordinates: Boston center + @lat, @lng = 42.358431, -71.059773 + @zoom = 15 + address, city, state = params[:address], params[:city], params[:state] + if address && city && state + @lat, @lng = Address.find_lat_lng("#{address}, #{city}, #{state}") + @zoom = 18 + end + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b82dd90..3491a20 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,8 +5,19 @@ <%= stylesheet_link_tag "main" %> <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" %> <%= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" %> - <%= javascript_include_tag "maps" %> <%= javascript_include_tag "snowstorm" %> + <%= csrf_meta_tag %> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index c135305..566020f 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -3,29 +3,19 @@

Claim responsibility for shoveling out a fire hydrant after it snows.

-
- - - - - - - -
- - - - + <%= form_tag root_path, :method => :get do %> + <%= label_tag "address" %> + <%= text_field_tag "address", params[:address], :tabindex => 1 %> + <%= label_tag "city" %> + <%= select_tag "city", ''.html_safe, :tabindex => 2 %> + <%= label_tag "state" %> + <%= select_tag "state", ''.html_safe, :tabindex => 3 %> + <%= submit_tag "Find Fire Hydrants", :tabindex => 4 %> + <% end %> + <%= image_tag "logos/boston.png", :alt => "City of Boston", :title => "City of Boston" %> + <%= image_tag "logos/cert.png", :alt => "Community Emergency Response Team", :title => "Community Emergency Response Team" %> + <%= image_tag "logos/cfa.png", :alt => "Code for America", :title => "Code for America" %> + <%= image_tag "hydrant-in-snow.jpg" %>
diff --git a/config/routes.rb b/config/routes.rb index ea8c50d..8d9bd4b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,58 +1,4 @@ AdoptAHydrant::Application.routes.draw do - # The priority is based upon order of creation: - # first created -> highest priority. - - # Sample of regular route: - # match 'products/:id' => 'catalog#view' - # Keep in mind you can assign values other than :controller and :action - - # Sample of named route: - # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase - # This route can be invoked with purchase_url(:id => product.id) - - # Sample resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Sample resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Sample resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Sample resource route with more complex sub-resources - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', :on => :collection - # end - # end - - # Sample resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end - - # You can have the root of your site routed with "root" - # just remember to delete public/index.html. + get "javascripts/:action" => "javascripts#action" root :to => "welcome#index" - - # See how all your routes lay out with "rake routes" - - # This is a legacy wild controller route that's not recommended for RESTful applications. - # Note: This route will make all actions in every controller accessible via GET requests. - # match ':controller(/:action(/:id(.:format)))' end diff --git a/public/javascripts/maps.js b/public/javascripts/maps.js deleted file mode 100644 index bf9c28f..0000000 --- a/public/javascripts/maps.js +++ /dev/null @@ -1,12 +0,0 @@ -$(function() { - var map; - - var latlng = new google.maps.LatLng(42.358431,-71.059773); - var myOptions = { - zoom: 15, - center: latlng, - mapTypeId: google.maps.MapTypeId.ROADMAP - }; - map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); - -}) diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index cccaa30..1c9e288 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -48,14 +48,13 @@ label, input { text-align: left; } -input, select, option, button { +input, select, option, input[type="submit"] { margin-bottom: 10px; font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif; font-size: 1.0em; width: 100%; } -button { +input[type="submit"] { text-align: center; - height: 2em; }