mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Fix tab toggle
This commit is contained in:
@@ -5,15 +5,13 @@ Darkswarm.directive "tabsetCtrl", (Tabsets, $location) ->
|
||||
selected: "@"
|
||||
navigate: "="
|
||||
prefix: "@?"
|
||||
alwaysopen: "="
|
||||
controller: ($scope, $element) ->
|
||||
if $scope.navigate
|
||||
path = $location.path()?.match(/^\/\w+$/)?[0]
|
||||
$scope.selected = path[1..] if path
|
||||
|
||||
this.toggle = (name) ->
|
||||
state = if $scope.alwaysopen then 'open' else null
|
||||
Tabsets.toggle($scope.id, name, state)
|
||||
Tabsets.toggle($scope.id, name)
|
||||
|
||||
this.select = (selection) ->
|
||||
$scope.$broadcast("selection:changed", selection)
|
||||
|
||||
@@ -7,12 +7,10 @@ Darkswarm.factory 'Tabsets', ->
|
||||
@tabsets.push { ctrl: ctrl, id: id, selected: selected }
|
||||
ctrl.select(selected) if selected?
|
||||
|
||||
toggle: (id, name, state=null) ->
|
||||
toggle: (id, name) ->
|
||||
tabset = @findTabsetByObject(id)
|
||||
if tabset.selected == name
|
||||
@select(tabset, null) unless state == "open"
|
||||
else
|
||||
@select(tabset, name) unless state == "closed"
|
||||
if tabset.selected != name
|
||||
@select(tabset, name)
|
||||
|
||||
select: (tabset, name) ->
|
||||
tabset.selected = name
|
||||
|
||||
Reference in New Issue
Block a user