diff --git a/app/assets/images/map-icon-hub.svg b/app/assets/images/map-icon-hub.svg new file mode 100644 index 0000000000..56030e2446 --- /dev/null +++ b/app/assets/images/map-icon-hub.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + diff --git a/app/assets/images/map-icon-producer.svg b/app/assets/images/map-icon-producer.svg new file mode 100644 index 0000000000..b636cb0db8 --- /dev/null +++ b/app/assets/images/map-icon-producer.svg @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/assets/javascripts/darkswarm/controllers/map_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/map_controller.js.coffee index cfa1f28693..383aedcee3 100644 --- a/app/assets/javascripts/darkswarm/controllers/map_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/map_controller.js.coffee @@ -1,10 +1,9 @@ -Darkswarm.controller "MapCtrl", ($scope, MapConfiguration, OfnMap, Marker)-> +Darkswarm.controller "MapCtrl", ($scope, MapConfiguration, OfnMap)-> $scope.OfnMap = OfnMap - console.log Marker - window.Marker = Marker $scope.map = center: latitude: -37.775757 longitude: 144.743663 zoom: 8 styles: MapConfiguration.options + diff --git a/app/assets/javascripts/darkswarm/services/map.js.coffee b/app/assets/javascripts/darkswarm/services/map.js.coffee new file mode 100644 index 0000000000..9140b9de22 --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/map.js.coffee @@ -0,0 +1,14 @@ +Darkswarm.factory "OfnMap", (enterprisesForMap, MapModal)-> + new class OfnMap + constructor: -> + @enterprises = (@extend(enterprise) for enterprise in enterprisesForMap) + + # Adding methods to each enterprise + extend: (enterprise)-> + new class MapMarker + icon: "/test.opng" + constructor: -> + @[k] = v for k, v of enterprise + + reveal: => + MapModal.open @ diff --git a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee new file mode 100644 index 0000000000..e6631a92f4 --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee @@ -0,0 +1,6 @@ +Darkswarm.factory "MapModal", ($modal, $rootScope)-> + new class MapModal + open: (enterprise)-> + scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise + scope.enterprise = enterprise + $modal.open(templateUrl: "map_modal.html", scope: scope) diff --git a/app/assets/javascripts/templates/map_modal.html.haml b/app/assets/javascripts/templates/map_modal.html.haml new file mode 100644 index 0000000000..4e2067f7d0 --- /dev/null +++ b/app/assets/javascripts/templates/map_modal.html.haml @@ -0,0 +1,48 @@ +.row + .small-12.columns.producer-hero + %h3.producer-name + %i.ofn-i_036-producers + {{ producer.name }} + %img.producer-hero-img{"ng-src" => "{{enterprise.promo_image}}"} + +.row + .small-12.large-6.columns + %p{"ng-bind-html" => "enterprise.long_description"} + .small-12.large-6.columns + %img.producer-logo{"ng-src" => "{{enterprise.logo}}", "ng-if" => "enterprise.logo"} + %h5 Stay in touch with {{ enterprise.name }} + + %ul.small-block-grid-1{bindonce: true} + + %li{"ng-if" => "enterprise.website"} + %a{"ng-href" => "http://{{enterprise.website | stripUrl}}", target: "_blank" } + %i.ofn-i_049-web + {{ enterprise.website | stripUrl }} + + %li{"ng-if" => "enterprise.email"} + %a{"ng-href" => "mailto:{{enterprise.email | stripUrl}}", target: "_blank" } + %i.ofn-i_050-mail-circle + {{ enterprise.email | stripUrl }} + + %li{"ng-if" => "enterprise.twitter"} + %a{"ng-href" => "http://twitter.com/{{enterprise.twitter}}", target: "_blank"} + %i.ofn-i_041-twitter + {{ enterprise.twitter }} + + %li{"ng-if" => "enterprise.facebook"} + %a{"ng-href" => "http://{{enterprise.facebook | stripUrl}}", target: "_blank"} + %i.ofn-i_044-facebook + {{ enterprise.facebook | stripUrl }} + + %li{"ng-if" => "enterprise.linkedin"} + %a{"ng-href" => "http://{{enterprise.linkedin | stripUrl}}", target: "_blank"} + %i.ofn-i_042-linkedin + {{ enterprise.linkedin | stripUrl }} + + %li{"ng-if" => "enterprise.instagram"} + %a{"ng-href" => "http://instagram.com/{{enterprise.instagram}}", target: "_blank"} + %i.ofn-i_043-instagram + {{ enterprise.instagram }} + + %a.close-reveal-modal{"ng-click" => "$close()"} + %i.ofn-i_009-close diff --git a/app/views/json/_enterprises_for_map.rabl b/app/views/json/_enterprises_for_map.rabl new file mode 100644 index 0000000000..da50f7eaf3 --- /dev/null +++ b/app/views/json/_enterprises_for_map.rabl @@ -0,0 +1,11 @@ +collection @enterprises +extends 'json/enterprises' +attributes :latitude, :longitude + +node :icon do |e| + if e.is_primary_producer? + image_path "map-icon-producer.svg" + else + image_path "map-icon-hub.svg" + end +end diff --git a/app/views/map/index.html.haml b/app/views/map/index.html.haml index 712e835cfe..efc1752baf 100644 --- a/app/views/map/index.html.haml +++ b/app/views/map/index.html.haml @@ -4,9 +4,6 @@ = inject_json "enterprisesForMap" , "enterprises_for_map", collection: @enterprises %map{"ng-controller" => "MapCtrl"} - %span{"ng-repeat" => "marker in OfnMap.enterprises"} - {{ marker.visible }} - %google-map{center: "map.center", zoom: "map.zoom", styles: "map.styles", draggable: "true"} %markers{models: "OfnMap.enterprises", fit: "true",