diff --git a/app/models/venue.rb b/app/models/venue.rb index b0cd2b0e..25d3b8cd 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -23,6 +23,10 @@ class Venue < ActiveRecord::Base name.name if name end + def location? + !(latitude.blank? || longitude.blank?) + end + private def send_mail_notification diff --git a/app/views/admin/venues/show.html.haml b/app/views/admin/venues/show.html.haml index 17404040..18266ede 100644 --- a/app/views/admin/venues/show.html.haml +++ b/app/views/admin/venues/show.html.haml @@ -25,10 +25,11 @@ = @venue.country_name .row .col-md-12 - = link_to(edit_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary', disabled: !(can? :update, @venue) ) do - Edit Venue - = link_to(admin_conference_venue_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', disabled: !(can? :destroy, @venue)) do - Delete Venue + %p.text-right + = link_to(edit_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary', disabled: !(can? :update, @venue) ) do + Edit Venue + = link_to(admin_conference_venue_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', disabled: !(can? :destroy, @venue)) do + Delete Venue -else .row .col-md-12.text-right diff --git a/app/views/conference/_venue.html.haml b/app/views/conference/_venue.html.haml index c07c5f8f..b2b7874b 100644 --- a/app/views/conference/_venue.html.haml +++ b/app/views/conference/_venue.html.haml @@ -1,42 +1,8 @@ = content_for :splash_nav do %li %a.smoothscroll{ href: '#venue' } Venue --if !@conference.venue.latitude.blank? and !@conference.venue.longitude.blank? - #map{style: "height: 500px;" } - - popup = "

#{@conference.venue.name}


#{@conference.venue.street}
#{@conference.venue.city}
#{@conference.venue.country_name}" - - content_for(:script_body) do - :javascript - L.Icon.Default.imagePath = '/assets/leaflet/'; - // 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('http://{s}.tile.osm.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%' - }); +-if @conference.venue.location? + = render 'conference/venue_map' -else .container .row diff --git a/app/views/conference/_venue_map.html.haml b/app/views/conference/_venue_map.html.haml new file mode 100644 index 00000000..eb1bbaee --- /dev/null +++ b/app/views/conference/_venue_map.html.haml @@ -0,0 +1,35 @@ +#map{style: "height: 500px;" } +- popup = "

#{@conference.venue.name}


#{@conference.venue.street}
#{@conference.venue.city}
#{@conference.venue.country_name}" +- content_for(:script_body) do + :javascript + L.Icon.Default.imagePath = '/assets/leaflet/'; + // 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('http://{s}.tile.osm.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%' + });