Factor HTML into templates

This commit is contained in:
Erik Michaels-Ober 2011-02-28 22:42:16 -08:00
parent 6b78540653
commit a30d0b26d0
4 changed files with 43 additions and 44 deletions

View File

@ -19,52 +19,10 @@
var redMarker = '/images/markers/red.png'; var redMarker = '/images/markers/red.png';
var greenMarker = '/images/markers/green.png'; var greenMarker = '/images/markers/green.png';
var openInfoWindow; var openInfoWindow;
var formString = '\ var formString = '<%= render(:partial => "adoption_form").gsub("\n", "") %>'
<div class="box">\
<h2>Adopt this Hydrant</h2>\
<%= form_tag do %>\
<div class="common_fields">\
<%= label_tag "email" %>\
<%= text_field_tag "email", params[:email], :tabindex => 1 %>\
<%= label_tag "account_new" , radio_button_tag("account", "new", true, :tabindex => 2).html_safe + "I haven\\'t signed up yet" %><br />\
<%= label_tag "account_existing", radio_button_tag("account", "existing").html_safe + "I already signed up" %><br />\
</div>\
<div class="account_new_fields">\
<%= label_tag "name" %>\
<%= text_field_tag "name", params[:name], :tabindex => 3 %>\
<%= label_tag "organization" %>\
<%= text_field_tag "organization", params[:organization], :tabindex => 4 %>\
<%= label_tag "voice_number" %>\
<%= text_field_tag "voice_number", params[:voice_number], :tabindex => 5 %>\
<%= label_tag "sms_number", "SMS number" %>\
<%= text_field_tag "sms_number", params[:sms_number], :tabindex => 6 %>\
<%= label_tag "password", "Choose a password" %>\
<%= password_field_tag "password", nil, :tabindex => 7 %>\
<%= submit_tag "Sign up", :tabindex => 8 %>\
<p>By signing up you accept the <%= link_to "Terms of Service", "#", :tabindex => 9 %>.</p>\
</div>\
<div class="account_existing_fields" style="display: none;">\
<%= label_tag "password" %>\
<%= password_field_tag "password", nil, :tabindex => 0 %>\
<%= label_tag "remember_me", check_box_tag("remember_me", nil, true).html_safe + "Stay signed in" %><br />\
<%= submit_tag "Sign in", :tabindex => 0 %>\
<p><%= link_to "Forgot your password?", "#", :class => "forgot_password", :tabindex => 0 %></p>\
</div>\
<div class="forgot_password_fields" style="display: none;">\
<%= submit_tag "Email me my password", :tabindex => 0 %>\
<p><%= link_to "Never mind. I remembered my password.", "#", :class => "remembered_password", :tabindex => 0 %></p>\
</div>\
<% end %>\
</div>\
';
<% @hydrants.each do |hydrant| %> <% @hydrants.each do |hydrant| %>
<% if user = hydrant.user %> <% if user = hydrant.user %>
<% require 'digest/md5' %> var contentString = '<%= render(:partial => "user_profile", :locals => {:user => user}).gsub("\n", "") %>'
<% hash = Digest::MD5.hexdigest(user.email) %>
var contentString = '\
<h2>Adopted by <%= hydrant.user.name %></h2>\
<a class="button">Email a reminder to shovel</a>\
'
<% else %> <% else %>
var contentString = formString; var contentString = formString;
<% end %> <% end %>

View File

@ -0,0 +1,36 @@
<div class="box">
<h2>Adopt this Hydrant</h2>
<%= form_tag do %>
<div class="common_fields">
<%= label_tag "email" %>
<%= text_field_tag "email", params[:email], :tabindex => 1 %>
<%= label_tag "account_new" , radio_button_tag("account", "new", true, :tabindex => 2).html_safe + "I haven\\'t signed up yet" %><br />
<%= label_tag "account_existing", radio_button_tag("account", "existing").html_safe + "I already signed up" %><br />
</div>
<div class="account_new_fields">
<%= label_tag "name" %>
<%= text_field_tag "name", params[:name], :tabindex => 3 %>
<%= label_tag "organization" %>
<%= text_field_tag "organization", params[:organization], :tabindex => 4 %>
<%= label_tag "voice_number" %>
<%= text_field_tag "voice_number", params[:voice_number], :tabindex => 5 %>
<%= label_tag "sms_number", "SMS number" %>
<%= text_field_tag "sms_number", params[:sms_number], :tabindex => 6 %>
<%= label_tag "password", "Choose a password" %>
<%= password_field_tag "password", nil, :tabindex => 7 %>
<%= submit_tag "Sign up", :tabindex => 8 %>
<p>By signing up you accept the <%= link_to "Terms of Service", "#", :tabindex => 9 %>.</p>
</div>
<div class="account_existing_fields" style="display: none;">
<%= label_tag "password" %>
<%= password_field_tag "password", nil, :tabindex => 0 %>
<%= label_tag "remember_me", check_box_tag("remember_me", nil, true).html_safe + "Stay signed in" %><br />
<%= submit_tag "Sign in", :tabindex => 0 %>
<p><%= link_to "Forgot your password?", "#", :class => "forgot_password", :tabindex => 0 %></p>
</div>
<div class="forgot_password_fields" style="display: none;">
<%= submit_tag "Email me my password", :tabindex => 0 %>
<p><%= link_to "Never mind. I remembered my password.", "#", :class => "remembered_password", :tabindex => 0 %></p>
</div>
<% end %>
</div>

View File

@ -0,0 +1,4 @@
<h2>Adopted by <%= user.name %></h2>
<% if user.organization %>
<h3>of <%= user.organization %></h3>
<% end %>

View File

@ -10,6 +10,7 @@ body {
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
font-family: Helvetica, Arial, sans-serif;
text-align: center; text-align: center;
} }