This commit is contained in:
Erik Michaels-Ober 2011-03-17 19:33:20 -07:00
parent df6689ddf5
commit cc07af72fb
8 changed files with 17 additions and 20 deletions

View File

@ -1,4 +1,4 @@
class FormsController < ApplicationController
class ContentsController < ApplicationController
def index
@hydrant = Hydrant.find_by_id(params[:hydrant_id])
if @hydrant.adopted?

View File

@ -1,4 +1,4 @@
<%= form_for @hydrant, :remote => true, :html => {:id => "adoption_form"} do |f| %>
<%= form_for @hydrant, :html => {:id => "adoption_form"} do |f| %>
<h2>Adopt this Hydrant</h2>
<div id="adoption_fields">
<%= f.hidden_field "id" %>

View File

@ -1,4 +1,4 @@
<%= form_for :user, :remote => true, :html => {:id => "combo_form"} do |f| %>
<%= form_for :user, :html => {:id => "combo_form"} do |f| %>
<h2>Adopt this Hydrant</h2>
<div id="common_fields">
<%= f.label "email", "Email address", :id => "user_email_label" %>

View File

@ -1,17 +1,14 @@
$(function() {
var center = new google.maps.LatLng(42.358431, -71.059773);
var southWest;
var northEast;
var bounds;
var zoomLevel = 15;
var myOptions = {
var mapOptions = {
center: center,
mapTypeControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: false,
zoom: zoomLevel
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var activeHydrantId;
var activeMarker;
var activeInfoWindow;
@ -41,7 +38,7 @@ $(function() {
if(activeInfoWindow) {
activeInfoWindow.close();
}
$.get('<%= forms_path %>', {
$.get('<%= contents_path %>', {
'hydrant_id': hydrantId
}, function(data) {
var infoWindow = new google.maps.InfoWindow({
@ -58,9 +55,9 @@ $(function() {
}
function addMarkersAround(lat, lng) {
$.get('<%= hydrants_path :format => "json" %>', {
'commit': $('#location_submit').val(),
'commit': $('#address_submit').val(),
'utf8': '✓',
'authenticity_token': $('#location_form input[name="authenticity_token"]').val(),
'authenticity_token': $('#address_form input[name="authenticity_token"]').val(),
'lat': lat,
'lng': lng
}, function(data) {
@ -108,16 +105,16 @@ $(function() {
center = map.getCenter();
addMarkersAround(center.lat(), center.lng());
});
$('#location_form').submit(function() {
$('#address_form').submit(function() {
if($('#address').val() === '') {
$('#address_label').addClass('error', 500);
$('#address').addClass('error', 500);
$('#address').focus();
} else {
$.get('<%= address_path :format => "json" %>', {
'commit': $('#location_submit').val(),
'commit': $('#address_submit').val(),
'utf8': '✓',
'authenticity_token': $('#location_form input[name="authenticity_token"]').val(),
'authenticity_token': $('#address_form input[name="authenticity_token"]').val(),
'city_state': $('#city_state').val(),
'address': $('#address').val()
}, function(data) {
@ -234,7 +231,7 @@ $(function() {
}
errors[0].focus();
} else {
$.get('<%= forms_path %>', {
$.get('<%= contents_path %>', {
'hydrant_id': activeHydrantId
}, function(data) {
activeInfoWindow.setContent(data);
@ -269,7 +266,7 @@ $(function() {
$('#user_password').addClass('error', 500);
$('#user_password').focus();
} else {
$.get('<%= forms_path %>', {
$.get('<%= contents_path %>', {
'hydrant_id': activeHydrantId
}, function(data) {
activeInfoWindow.setContent(data);
@ -314,7 +311,7 @@ $(function() {
'name': $('#hydrant_name').val()
}
}, function(data) {
$.get('<%= forms_path %>', {
$.get('<%= contents_path %>', {
'hydrant_id': activeHydrantId
}, function(data) {
activeInfoWindow.setContent(data);

View File

@ -3,12 +3,12 @@
<p id="tagline">
Claim responsibility for shoveling out a fire hydrant after it snows.
</p>
<%= form_tag "/", :method => "GET", :id => "location_form" do %>
<%= form_for :address, :html => {:id => "address_form"} do |f| %>
<%= label_tag "city_state", "City", :id => "city_label" %>
<%= select_tag "city_state", '<option value="Boston, MA" selected="selected">Boston, MA</option>'.html_safe, :tabindex => 10 %>
<%= label_tag "address", "Address", :id => "address_label" %>
<%= text_field_tag "address", params[:address], :tabindex => 11 %>
<%= submit_tag "Find Fire Hydrants", :id => "location_submit", :tabindex => 12 %>
<%= submit_tag "Find Fire Hydrants", :id => "address_submit", :tabindex => 12 %>
<% end %>
<div id="logos">
<%= image_tag "logos/cfa.png", :alt => "Code for America", :title => "Code for America" %>

View File

@ -12,6 +12,6 @@ AdoptAHydrant::Application.routes.draw do
end
get 'address' => 'addresses#index', :as => 'address'
get 'sitemap' => 'sitemaps#index', :as => 'sitemap'
get 'forms' => 'forms#index', :as => 'forms'
get 'contents' => 'contents#index', :as => 'contents'
root :to => 'main#index'
end