diff --git a/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee index 7d1845cea7..c53f760e7d 100644 --- a/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee @@ -8,12 +8,5 @@ Darkswarm.controller "HubNodeCtrl", ($scope, HashNavigation, Navigation, $locati $scope.current = -> $scope.hub.id is CurrentHub.id - $scope.emptiesCart = -> - CurrentHub.id isnt undefined and !$scope.current() - - $scope.changeHub = -> - if confirm "Are you sure? This will change your selected Hub and remove any items in you shopping cart." - Navigation.go $scope.hub.path - if $scope.open() $anchorScroll() diff --git a/app/assets/javascripts/darkswarm/directives/empties_cart.js.coffee b/app/assets/javascripts/darkswarm/directives/empties_cart.js.coffee new file mode 100644 index 0000000000..58595f9e24 --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/empties_cart.js.coffee @@ -0,0 +1,16 @@ +Darkswarm.directive "ofnEmptiesCart", (CurrentHub, Navigation) -> + restrict: "A" + scope: + hub: '=ofnEmptiesCart' + template: "{{action}} {{hub.name}}" + link: (scope, elm, attr)-> + if CurrentHub.id and CurrentHub.id isnt scope.hub.id + scope.action = attr.change + elm.bind 'click', (ev)-> + ev.preventDefault() + if confirm "Are you sure? This will change your selected Hub and remove any items in you shopping cart." + Navigation.go scope.hub.path + else + scope.action = attr.shop + + diff --git a/app/views/home/_fat.html.haml b/app/views/home/_fat.html.haml index 86ef92cfdd..7d5dfb3b80 100644 --- a/app/views/home/_fat.html.haml +++ b/app/views/home/_fat.html.haml @@ -15,13 +15,8 @@ .row.active_table_row.link{"ng-show" => "open()", "ng-if" => "hub.active"} .columns.small-11 - %a{"bo-href" => "hub.path", "ng-show" => "!emptiesCart()"} - Shop at - - %strong {{ hub.name }} - %a{"ng-click" => "changeHub()", "ng-show" => "emptiesCart()"} - Change hub to - %strong {{ hub.name }} + %a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub", + change: "Change hub to", shop: "Shop at"} .columns.small-1.text-right %a{"bo-href" => "hub.path"} diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index 68acee1d12..45b3bf8dd0 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -3,21 +3,16 @@ %strong Shop for %p.trans-sentence {{ producer.taxons | printArrayOfObjects }} - .columns.small-4 + .columns.small-8 %strong About us %p.trans-sentence {{ producer.description }} - .columns.small-4 - %strong Our distributors - %ul - %li{"ng-repeat" => "distributor in producer.distributors"} - %a{"bo-href" => "distributor.path"}{{ distributor.name }} -.row.active_table_row.link{"ng-show" => "open()", "ng-repeat" => "hub in producer.hubs"} +.row.active_table_row.link{"ng-show" => "open()", "ng-repeat" => "hub in producer.distributors"} .columns.small-11 - %a{"bo-href" => "hub.path"} - Shop at - %strong {{ producer.name }} + %a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub", + change: "Change hub to", shop: "Shop at"} + .columns.small-1.text-right %a{"bo-href" => "hub.path"} %i.fi-arrow-right