Files
openfoodnetwork/app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee
Maikel Linke 9798b05a24 TabsCtrl can show tabs that don't toggle
toggle: tabs show on first click and hide on second click
select: tabs show on every click, one tab is always active
2015-01-06 22:39:15 +11:00

16 lines
453 B
CoffeeScript

Darkswarm.controller "TabsCtrl", ($scope, $rootScope, $location) ->
# Return active if supplied path matches url hash path.
$scope.active = (path)->
$location.hash() == path
# 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