adopt-a-hydrant/app/views/layouts/application.html.erb

106 lines
3.8 KiB
Plaintext

<!DOCTYPE html>
<html>
<head>
<title>Adopt a Hydrant</title>
<%= stylesheet_link_tag "main" %>
<%= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js" %>
<%= javascript_include_tag "https://github.com/scottschiller/Snowstorm/raw/master/snowstorm-min.js" %>
<script type="text/javascript">
$(function() {
var map;
var latlng = new google.maps.LatLng(<%= @lat %>, <%= @lng %>);
var myOptions = {
mapTypeControl: false,
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.BOTTOM_CENTER
},
zoom: <%= @zoom %>,
zoomControl: false,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var openInfoWindow;
var formString = '<%= render(:partial => "adoption_form").gsub("\n", "") %>'
function addMarker(point, color, contentString) {
var image = new google.maps.MarkerImage(color,
new google.maps.Size(27.0, 37.0),
new google.maps.Point(0, 0),
new google.maps.Point(13.0, 18.0)
);
var shadow = new google.maps.MarkerImage('/images/markers/shadow.png',
new google.maps.Size(46.0, 37.0),
new google.maps.Point(0, 0),
new google.maps.Point(13.0, 18.0)
);
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);
openInfoWindow = infoWindow;
});
}
<% @hydrants.each do |hydrant| %>
point = new google.maps.LatLng(<%= hydrant.lat %>, <%= hydrant.lng %>);
color = <%= hydrant.user_id ? "'/images/markers/green.png'" : "'/images/markers/red.png'" %>;
<% if user = hydrant.user %>
contentString = '<%= render(:partial => "user_profile", :locals => {:user => user}).gsub("\n", "") %>'
<% else %>
contentString = formString;
<% end %>
addMarker(point, color, contentString);
<% end %>
$('#location_form').submit(function() {
if($("#address").val() === "") {
$('#address_label').addClass('error', 500);
$('#address').addClass('error', 500);
$('#address').focus();
return false;
} else {
return true;
}
});
$('.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();
} else if('existing' == self.val()) {
$('.account_new_fields').slideUp();
$('.account_existing_fields').slideDown(function() {
$('.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();
});
});
});
});
}
});
})
</script>
<%= csrf_meta_tag %>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
</head>
<body>
<%= yield -%>
</body>
</html>