mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Hash Navigation works on with Group and Shopping page tabs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Darkswarm.controller "GroupPageCtrl", ($scope, group_enterprises, Enterprises, MapConfiguration, OfnMap, visibleFilter) ->
|
||||
Darkswarm.controller "GroupPageCtrl", ($scope, group_enterprises, Enterprises, MapConfiguration, OfnMap, visibleFilter, Navigation) ->
|
||||
$scope.Enterprises = Enterprises
|
||||
|
||||
all_enterprises_by_id = Enterprises.enterprises_by_id
|
||||
@@ -19,4 +19,3 @@ Darkswarm.controller "GroupPageCtrl", ($scope, group_enterprises, Enterprises, M
|
||||
|
||||
$scope.map = angular.copy MapConfiguration.options
|
||||
$scope.mapMarkers = OfnMap.enterprise_markers visible_enterprises
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
Darkswarm.controller "GroupTabsCtrl", ($scope, $controller, Navigation) ->
|
||||
angular.extend this, $controller('TabsCtrl', {$scope: $scope})
|
||||
|
||||
$scope.tabs =
|
||||
map: { active: Navigation.isActive('/map') }
|
||||
about: { active: Navigation.isActive('/about') }
|
||||
producers: { active: Navigation.isActive('/producers') }
|
||||
hubs: { active: Navigation.isActive('/hubs') }
|
||||
@@ -1,3 +1,3 @@
|
||||
Darkswarm.controller "GroupsCtrl", ($scope, Groups, $anchorScroll, $rootScope) ->
|
||||
Darkswarm.controller "GroupsCtrl", ($scope, Groups) ->
|
||||
$scope.Groups = Groups
|
||||
$scope.order = 'position'
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
Darkswarm.controller "ShoppingTabsCtrl", ($scope, $controller, Navigation) ->
|
||||
angular.extend this, $controller('TabsCtrl', {$scope: $scope})
|
||||
|
||||
$scope.tabs =
|
||||
about: { active: Navigation.isActive('/about') }
|
||||
producers: { active: Navigation.isActive('/producers') }
|
||||
contact: { active: Navigation.isActive('/contact') }
|
||||
groups: { active: Navigation.isActive('/groups') }
|
||||
@@ -1,15 +1,6 @@
|
||||
Darkswarm.controller "TabsCtrl", ($scope, $rootScope, $location) ->
|
||||
# Return active if supplied path matches url hash path.
|
||||
$scope.active = (path)->
|
||||
$location.hash() == path
|
||||
Darkswarm.controller "TabsCtrl", ($scope, Navigation) ->
|
||||
$scope.isActive = Navigation.isActive
|
||||
|
||||
# Select tab by setting the url hash path.
|
||||
$scope.select = (path)->
|
||||
$location.hash path
|
||||
|
||||
# Toggle tab selected status by setting the url hash path.
|
||||
$scope.toggle = (path)->
|
||||
if $scope.active(path)
|
||||
$location.hash ""
|
||||
else
|
||||
$location.hash path
|
||||
$scope.select = (path) ->
|
||||
Navigation.navigate path
|
||||
|
||||
@@ -32,27 +32,27 @@
|
||||
.small-12.columns.pad-top
|
||||
.row
|
||||
.small-12.medium-12.large-9.columns
|
||||
%div{"ng-controller" => "TabsCtrl"}
|
||||
%div{"ng-controller" => "GroupTabsCtrl"}
|
||||
%tabset
|
||||
%tab{heading: t(:label_map),
|
||||
active: "active(\'\')",
|
||||
select: "select(\'\')"}
|
||||
active: "tabs.map.active",
|
||||
select: "select(\'map\')"}
|
||||
.map-container
|
||||
%map{"ng-if" => "(active(\'\') && (mapShowed = true)) || mapShowed"}
|
||||
%map{"ng-if" => "(isActive(\'/map\') && (mapShowed = true)) || mapShowed"}
|
||||
%google-map{options: "map.additional_options", center: "map.center", zoom: "map.zoom", styles: "map.styles", draggable: "true"}
|
||||
%map-search
|
||||
%markers{models: "mapMarkers", fit: "true",
|
||||
coords: "'self'", icon: "'icon'", click: "'reveal'"}
|
||||
|
||||
%tab{heading: t(:groups_about),
|
||||
active: "active(\'about\')",
|
||||
active: "tabs.about.active",
|
||||
select: "select(\'about\')"}
|
||||
%h1
|
||||
= t :groups_about
|
||||
%p!= @group.long_description
|
||||
|
||||
%tab{heading: t(:groups_producers),
|
||||
active: "active(\'producers\')",
|
||||
active: "tabs.producers.active",
|
||||
select: "select(\'producers\')"}
|
||||
.producers{"ng-controller" => "GroupEnterprisesCtrl"}
|
||||
.row
|
||||
@@ -78,7 +78,7 @@
|
||||
= render partial: 'shared/components/enterprise_no_results'
|
||||
|
||||
%tab{heading: t(:groups_hubs),
|
||||
active: "active(\'hubs\')",
|
||||
active: "tabs.hubs.active",
|
||||
select: "select(\'hubs\')"}
|
||||
.hubs{"ng-controller" => "GroupEnterprisesCtrl"}
|
||||
.row
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#tabs{"ng-controller" => "TabsCtrl", "ng-cloak" => true}
|
||||
#tabs{"ng-controller" => "ShoppingTabsCtrl", "ng-cloak" => true}
|
||||
.row
|
||||
%tabset{ 'open-on-load' => 'false' }
|
||||
-# Build all tabs.
|
||||
@@ -6,10 +6,10 @@
|
||||
producers: [t(:label_producers),2],
|
||||
contact: [t(:shopping_tabs_contact),2],
|
||||
groups: [t(:label_groups),2]}
|
||||
-# tabs take tab path in 'active' and 'select' functions defined in TabsCtrl.
|
||||
- heading, cols = heading_cols
|
||||
%tab.columns{heading: heading,
|
||||
id: "tab_#{name}",
|
||||
select: "toggle(\'#{name}\')",
|
||||
active: "tabs.#{name}.active",
|
||||
select: "select(\'#{name}\')",
|
||||
class: "small-12 medium-#{cols}" }
|
||||
= render "shopping_shared/#{name}"
|
||||
|
||||
Reference in New Issue
Block a user