2011-02-14 18:28:51 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
2011-02-14 18:49:00 +00:00
|
|
|
<head>
|
2011-02-23 22:24:08 +00:00
|
|
|
<title>Adopt a Hydrant</title>
|
2011-02-14 18:49:00 +00:00
|
|
|
<%= stylesheet_link_tag "main" %>
|
|
|
|
<%= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" %>
|
2011-03-05 01:43:25 +00:00
|
|
|
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" %>
|
2011-03-05 04:22:03 +00:00
|
|
|
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" %>
|
2011-03-04 23:21:08 +00:00
|
|
|
<%= javascript_include_tag "https://github.com/scottschiller/Snowstorm/raw/master/snowstorm-min.js" %>
|
2011-02-25 21:34:01 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
$(function() {
|
|
|
|
var map;
|
|
|
|
var latlng = new google.maps.LatLng(<%= @lat %>, <%= @lng %>);
|
|
|
|
var myOptions = {
|
2011-03-01 08:20:55 +00:00
|
|
|
mapTypeControl: false,
|
|
|
|
scaleControl: true,
|
|
|
|
scaleControlOptions: {
|
|
|
|
position: google.maps.ControlPosition.BOTTOM_CENTER
|
|
|
|
},
|
2011-02-25 21:34:01 +00:00
|
|
|
zoom: <%= @zoom %>,
|
2011-03-01 08:20:55 +00:00
|
|
|
zoomControl: false,
|
2011-02-25 21:34:01 +00:00
|
|
|
center: latlng,
|
|
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
|
|
|
};
|
|
|
|
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
2011-03-01 05:11:07 +00:00
|
|
|
var openInfoWindow;
|
2011-03-05 04:22:03 +00:00
|
|
|
var formString = '<%= render(:partial => "combo_form").gsub("\n", "") %>'
|
2011-03-01 08:20:55 +00:00
|
|
|
function addMarker(point, color, contentString) {
|
|
|
|
var image = new google.maps.MarkerImage(color,
|
2011-03-03 18:26:41 +00:00
|
|
|
new google.maps.Size(27.0, 37.0),
|
2011-03-01 08:20:55 +00:00
|
|
|
new google.maps.Point(0, 0),
|
2011-03-03 18:26:41 +00:00
|
|
|
new google.maps.Point(13.0, 18.0)
|
2011-03-01 08:20:55 +00:00
|
|
|
);
|
|
|
|
var shadow = new google.maps.MarkerImage('/images/markers/shadow.png',
|
2011-03-03 18:26:41 +00:00
|
|
|
new google.maps.Size(46.0, 37.0),
|
2011-03-01 08:20:55 +00:00
|
|
|
new google.maps.Point(0, 0),
|
2011-03-03 18:26:41 +00:00
|
|
|
new google.maps.Point(13.0, 18.0)
|
2011-03-01 08:20:55 +00:00
|
|
|
);
|
|
|
|
var marker = new google.maps.Marker({
|
|
|
|
position: point,
|
|
|
|
map: map,
|
|
|
|
icon: image,
|
|
|
|
shadow: shadow
|
|
|
|
});
|
|
|
|
var infoWindow = new google.maps.InfoWindow({
|
|
|
|
content: contentString
|
|
|
|
});
|
|
|
|
google.maps.event.addListener(marker, 'click', function() {
|
|
|
|
if(openInfoWindow) {
|
|
|
|
openInfoWindow.close();
|
|
|
|
}
|
|
|
|
infoWindow.open(map, marker);
|
2011-03-05 04:22:03 +00:00
|
|
|
$('.combo_form').data('state', 'new');
|
|
|
|
$('.combo_form').submit(function() {
|
|
|
|
if($(this).data('state') === 'new') {
|
|
|
|
if($('.choose_password').val() === '') {
|
|
|
|
$('.choose_password').focus();
|
|
|
|
$('.choose_password_label').addClass('error', 500);
|
|
|
|
$('.choose_password').addClass('error', 500);
|
|
|
|
} else {
|
|
|
|
$('.choose_password_label').removeClass('error', 500);
|
|
|
|
$('.choose_password').removeClass('error', 500);
|
|
|
|
}
|
|
|
|
if($('.name').val() === '') {
|
|
|
|
$('.name').focus();
|
|
|
|
$('.name_label').addClass('error', 500);
|
|
|
|
$('.name').addClass('error', 500);
|
|
|
|
} else {
|
|
|
|
$('.name_label').removeClass('error', 500);
|
|
|
|
$('.name').removeClass('error', 500);
|
|
|
|
}
|
|
|
|
} else if($(this).data('state') === 'existing') {
|
|
|
|
if($('.password').val() === '') {
|
|
|
|
$('.password').focus();
|
|
|
|
$('.password_label').addClass('error', 500);
|
|
|
|
$('.password').addClass('error', 500);
|
|
|
|
} else {
|
|
|
|
$('.password_label').removeClass('error', 500);
|
|
|
|
$('.password').removeClass('error', 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]+$/.test($('.email').val())) {
|
|
|
|
$('.email').focus();
|
|
|
|
$('.email_label').addClass('error', 500);
|
|
|
|
$('.email').addClass('error', 500);
|
|
|
|
} else {
|
|
|
|
$('.email_label').removeClass('error', 500);
|
|
|
|
$('.email').removeClass('error', 500);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2011-03-01 08:20:55 +00:00
|
|
|
openInfoWindow = infoWindow;
|
|
|
|
});
|
|
|
|
}
|
2011-03-01 05:11:07 +00:00
|
|
|
<% @hydrants.each do |hydrant| %>
|
2011-03-01 08:20:55 +00:00
|
|
|
point = new google.maps.LatLng(<%= hydrant.lat %>, <%= hydrant.lng %>);
|
|
|
|
color = <%= hydrant.user_id ? "'/images/markers/green.png'" : "'/images/markers/red.png'" %>;
|
2011-03-01 05:11:07 +00:00
|
|
|
<% if user = hydrant.user %>
|
2011-03-01 08:20:55 +00:00
|
|
|
contentString = '<%= render(:partial => "user_profile", :locals => {:user => user}).gsub("\n", "") %>'
|
2011-03-01 05:11:07 +00:00
|
|
|
<% else %>
|
2011-03-01 08:20:55 +00:00
|
|
|
contentString = formString;
|
2011-03-01 04:13:31 +00:00
|
|
|
<% end %>
|
2011-03-01 08:20:55 +00:00
|
|
|
addMarker(point, color, contentString);
|
2011-02-25 21:49:45 +00:00
|
|
|
<% end %>
|
2011-03-05 01:43:25 +00:00
|
|
|
$('#location_form').submit(function() {
|
2011-03-05 04:22:03 +00:00
|
|
|
if($('#address').val() === '') {
|
|
|
|
$('#address').focus();
|
2011-03-05 01:43:25 +00:00
|
|
|
$('#address_label').addClass('error', 500);
|
|
|
|
$('#address').addClass('error', 500);
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2011-03-01 04:13:31 +00:00
|
|
|
$('.box input[type="radio"]').live('click', function() {
|
|
|
|
var self = $(this);
|
|
|
|
if('new' == self.val()) {
|
|
|
|
$('.forgot_password_fields').slideUp();
|
|
|
|
$('.account_existing_fields').slideUp();
|
|
|
|
$('.account_new_fields').slideDown();
|
2011-03-05 04:22:03 +00:00
|
|
|
$('.combo_form').data('state', 'new');
|
2011-03-01 04:13:31 +00:00
|
|
|
} else if('existing' == self.val()) {
|
|
|
|
$('.account_new_fields').slideUp();
|
|
|
|
$('.account_existing_fields').slideDown(function() {
|
2011-03-05 04:22:03 +00:00
|
|
|
$('.combo_form').data('state', 'existing');
|
2011-03-01 04:13:31 +00:00
|
|
|
$('.forgot_password').click(function() {
|
|
|
|
$('.account_existing_fields').slideUp();
|
|
|
|
$('.forgot_password_fields').slideDown(function() {
|
|
|
|
$('.remembered_password').click(function() {
|
|
|
|
$('.forgot_password_fields').slideUp();
|
|
|
|
$('.account_existing_fields').slideDown();
|
2011-03-05 04:22:03 +00:00
|
|
|
$('.combo_form').data('state', 'existing');
|
2011-03-01 04:13:31 +00:00
|
|
|
});
|
|
|
|
});
|
2011-03-05 04:22:03 +00:00
|
|
|
$('.combo_form').data('state', 'forgot_password');
|
2011-03-01 04:13:31 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2011-02-25 21:34:01 +00:00
|
|
|
})
|
|
|
|
</script>
|
2011-02-14 18:49:00 +00:00
|
|
|
<%= csrf_meta_tag %>
|
|
|
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
|
|
|
</head>
|
2011-02-14 20:27:18 +00:00
|
|
|
<body>
|
2011-02-14 18:49:00 +00:00
|
|
|
<%= yield -%>
|
|
|
|
</body>
|
2011-02-14 18:28:51 +00:00
|
|
|
</html>
|