From 653da728c6a38b8f1728ed6b5a415a41cfb7c8d1 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 17 Jun 2014 12:35:03 +1000 Subject: [PATCH] Starting a set of small functional changes --- .../darkswarm/services/map_modal.js.coffee | 5 +- .../templates/map_modal_hub.html.haml | 49 +++++++++++++++++++ ...html.haml => map_modal_producer.html.haml} | 0 .../stylesheets/darkswarm/ie_warning.sass | 9 ++++ app/controllers/map_controller.rb | 1 + app/views/home/_fat.html.haml | 14 +++++- app/views/json/_enterprises_for_map.rabl | 7 ++- app/views/layouts/darkswarm.html.haml | 7 +++ 8 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/templates/map_modal_hub.html.haml rename app/assets/javascripts/templates/{map_modal.html.haml => map_modal_producer.html.haml} (100%) create mode 100644 app/assets/stylesheets/darkswarm/ie_warning.sass diff --git a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee index e6631a92f4..d26384cc48 100644 --- a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee @@ -3,4 +3,7 @@ Darkswarm.factory "MapModal", ($modal, $rootScope)-> open: (enterprise)-> scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise scope.enterprise = enterprise - $modal.open(templateUrl: "map_modal.html", scope: scope) + if enterprise['is_primary_producer?'] + $modal.open(templateUrl: "map_modal_producer.html", scope: scope) + else + $modal.open(templateUrl: "map_modal_hub.html", scope: scope) diff --git a/app/assets/javascripts/templates/map_modal_hub.html.haml b/app/assets/javascripts/templates/map_modal_hub.html.haml new file mode 100644 index 0000000000..4b5fab15fb --- /dev/null +++ b/app/assets/javascripts/templates/map_modal_hub.html.haml @@ -0,0 +1,49 @@ +.row + .small-12.columns.producer-hero + %h3.producer-name + %i.ofn-i_040-hub + {{ enterprise.name }} + {{ enterprise.id }} + %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/assets/javascripts/templates/map_modal.html.haml b/app/assets/javascripts/templates/map_modal_producer.html.haml similarity index 100% rename from app/assets/javascripts/templates/map_modal.html.haml rename to app/assets/javascripts/templates/map_modal_producer.html.haml diff --git a/app/assets/stylesheets/darkswarm/ie_warning.sass b/app/assets/stylesheets/darkswarm/ie_warning.sass new file mode 100644 index 0000000000..f0fc9099ee --- /dev/null +++ b/app/assets/stylesheets/darkswarm/ie_warning.sass @@ -0,0 +1,9 @@ +#ie-warning + background: white + position: fixed + top: 0 + z-index: 200 + left: 0 + width: 100% + font-size: 1.2em + padding: 20px diff --git a/app/controllers/map_controller.rb b/app/controllers/map_controller.rb index e4c4627f5f..b5c9ceba83 100644 --- a/app/controllers/map_controller.rb +++ b/app/controllers/map_controller.rb @@ -1,6 +1,7 @@ class MapController < BaseController layout 'darkswarm' def index + @active_distributors ||= Enterprise.distributors_with_active_order_cycles @enterprises = Enterprise.visible end end diff --git a/app/views/home/_fat.html.haml b/app/views/home/_fat.html.haml index 25c48006e8..11af6e2454 100644 --- a/app/views/home/_fat.html.haml +++ b/app/views/home/_fat.html.haml @@ -24,7 +24,7 @@ %li{"ng-repeat" => "producer in hub.producers"} = render partial: "modals/producer" -.row.active_table_row.link{"ng-show" => "open()", "ng-if" => "hub.active"} +.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "hub.active"} .columns.small-11 %a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub", change: "Change hub to", shop: "Shop at"} @@ -32,3 +32,15 @@ .columns.small-1.text-right %a{"bo-href" => "hub.path"} %i.ofn-i_007-caret-right + +.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "!hub.active"} + .columns.small-11 + %a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub", + change: "Change hub to (disabled)", shop: "Shop at (disabled)"} + + .columns.small-1.text-right + + %a{"bo-href" => "hub.path"} + %i.ofn-i_007-caret-right + + diff --git a/app/views/json/_enterprises_for_map.rabl b/app/views/json/_enterprises_for_map.rabl index 006f2e3cca..4da6309abc 100644 --- a/app/views/json/_enterprises_for_map.rabl +++ b/app/views/json/_enterprises_for_map.rabl @@ -1,14 +1,19 @@ collection @enterprises extends 'json/enterprises' -attributes :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook +attributes :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer?, :is_distributor? node :logo do |enterprise| enterprise.logo(:medium) if enterprise.logo.exists? end + node :promo_image do |enterprise| enterprise.promo_image(:large) if enterprise.promo_image.exists? end +node :active do |enterprise| + @active_distributors.include?(enterprise) +end + node :icon do |e| if e.is_primary_producer? and e.is_distributor? image_path "map-icon-both.svg" diff --git a/app/views/layouts/darkswarm.html.haml b/app/views/layouts/darkswarm.html.haml index da314d514c..5208c3d5ef 100644 --- a/app/views/layouts/darkswarm.html.haml +++ b/app/views/layouts/darkswarm.html.haml @@ -18,6 +18,13 @@ = csrf_meta_tags %body.off-canvas{"ng-app" => "Darkswarm"} + /[if lte IE 8] + #ie-warning + Your browser is very old! To use our site, you'll need to upgrade to + something a bit more modern, such as + %a{href: "https://www.google.com/intl/en_au/chrome/browser/"} Google Chrome + + = inject_json "currentHub", "current_hub" = inject_json "currentOrder", "current_order" = inject_json "user", "current_user"