Skip to content

Commit

Permalink
Bug fixes for chrome. Added Leaflet to vendor assets.
Browse files Browse the repository at this point in the history
  • Loading branch information
meiao committed Aug 12, 2015
1 parent c387180 commit a5551c4
Show file tree
Hide file tree
Showing 11 changed files with 501 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
//= require_tree .
//= require bootstrap
//= require leaflet
16 changes: 12 additions & 4 deletions app/assets/javascripts/housing_locations.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,37 @@ $ ->

# Map related events and initialization
$ ->
# checking if the map area and buttons exists
return if $('#housing-location-map').length == 0
buttons = $('button.housing-location-show-map')
return if buttons.length == 0

#initializing map
L.Icon.Default.imagePath = '/assets'
map = L.map('housing-location-map').setView([38.9, -77.0], 10)
marker = L.marker([38.9, -77.0]).addTo(map)
url = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png'
L.tileLayer(url, {
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map)

# initializing modal area
$('#housing-location-modal').on('shown.bs.modal', () ->
map.invalidateSize()
)

#setting up the buttons to show the map
buttons.click((event) ->
button = event.target
$('#housing-location-modal').modal()
housing_data = JSON.parse(button.getAttribute('housing-data'))
button = $(event.target)
# on firefox the event is triggered on the button, but on chrome, it may be
# triggered on the icon's span
while (!button.is('button'))
button = button.parent();
housing_data = JSON.parse(button.attr('housing-data'))
$('#housing-location-modal .modal-title').text(housing_data.name)
lat = housing_data.lat
long = housing_data.long
map.removeLayer(marker)
marker = L.marker([lat, long]).addTo(map);
map.setView([lat, long], 13)
$('#housing-location-modal').modal()
)
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@import "housing_form";
@import "pdf_guide";
@import "circle_progress";
@import "leaflet";
4 changes: 0 additions & 4 deletions app/views/housing_forms/_location_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- leaflet js and css -->
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
Binary file added vendor/assets/images/layers-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/marker-icon-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/marker-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/marker-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions vendor/assets/javascripts/leaflet.js

Large diffs are not rendered by default.

Loading

0 comments on commit a5551c4

Please sign in to comment.