diff --git a/app/views/admin/venues/_form.html.haml b/app/views/admin/venues/_form.html.haml index 7dd08a2c..8e021e3e 100644 --- a/app/views/admin/venues/_form.html.haml +++ b/app/views/admin/venues/_form.html.haml @@ -15,7 +15,7 @@ = semantic_form_for(@venue, url: admin_conference_venue_path(@conference.short_title)) do |f| = f.inputs :name, :website = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint - = f.inputs :street, :postalcode, :city, :country, :latitude, :longitude + = f.inputs :street, :postalcode, :city, :country = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } #commercials-content.tab-pane diff --git a/app/views/admin/venues/_venue_map.html.haml b/app/views/admin/venues/_venue_map.html.haml new file mode 100644 index 00000000..b58b3053 --- /dev/null +++ b/app/views/admin/venues/_venue_map.html.haml @@ -0,0 +1,34 @@ +#map{style: "height: 500px;" } +- popup = "

#{@conference.venue.name}


#{@conference.venue.street}
#{@conference.venue.city}
#{@conference.venue.country_name}" +- content_for(:script_body) do + :javascript + // create a map in the "map" div, set the view to a given place and zoom + var map = L.map('map', { scrollWheelZoom: false }).setView([#{@conference.venue.latitude}, #{@conference.venue.longitude}], 11); + // add an OpenStreetMap tile layer + L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', + maxZoom: 18 + }).addTo(map); + // add a marker in the given location, attach some popup content to it and open the popup + L.marker([#{@conference.venue.latitude}, #{@conference.venue.longitude}]).addTo(map) + .bindPopup("#{popup}") + .openPopup(); + // Turn scrollwheel on when user clicks + map.on('focus', function(e) { + map.scrollWheelZoom.enable(); + }); + // Turn scrollwheel off once the map isn't in the viewport anymore + $('#map').waypoint({ + handler: function(direction) { + map.scrollWheelZoom.disable(); + //alert('map'); + }, + offset: '90%' + }); + $('#map').waypoint({ + handler: function(direction) { + map.scrollWheelZoom.disable(); + //alert('map'); + }, + offset: '10%' + }); diff --git a/app/views/admin/venues/show.html.haml b/app/views/admin/venues/show.html.haml index b50c10da..5e25f52a 100644 --- a/app/views/admin/venues/show.html.haml +++ b/app/views/admin/venues/show.html.haml @@ -41,3 +41,5 @@ .col-md-12.text-right = link_to(new_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary') do Create Venue + +