Let shopping tabs listen to URL changes

When clicking on a shopping tab like "contact", it changed the URL. But
changing the URL did not change the tab. Listening to URL changes
enables manual manipulation of the URL and simple links to "#/contact"
to open the contact tab.
This commit is contained in:
Maikel Linke
2016-11-11 17:11:39 +11:00
parent b66cf14bcb
commit c0c8b07add
2 changed files with 6 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
Darkswarm.controller "ShoppingTabsCtrl", ($scope, $controller, Navigation) ->
Darkswarm.controller "ShoppingTabsCtrl", ($scope, $controller, Navigation, $location) ->
angular.extend this, $controller('TabsCtrl', {$scope: $scope})
$scope.tabs =
@@ -6,3 +6,7 @@ Darkswarm.controller "ShoppingTabsCtrl", ($scope, $controller, Navigation) ->
producers: { active: Navigation.isActive('/producers') }
contact: { active: Navigation.isActive('/contact') }
groups: { active: Navigation.isActive('/groups') }
$scope.$on '$locationChangeStart', (event, url) ->
tab = $location.path().replace(/^\//, '')
$scope.tabs[tab]?.active = true

View File

@@ -10,7 +10,7 @@
register: ('<a auth="signup">' + t('.register') + '</a>').html_safe}
- else
= t '.require_customer_html',
{contact: ('<a href="##contact">' + t('.contact') + '</a>').html_safe,
{contact: link_to(t('.contact'), '#contact'),
enterprise: current_distributor.name}
- elsif @order_cycles and @order_cycles.empty?
- if current_distributor.preferred_shopfront_closed_message.present?