From f5a03418518dd8d5c3f6d697b66559f9335ca367 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Wed, 26 Mar 2014 15:26:02 +1100 Subject: [PATCH] Notes for the tabs controller --- .../controllers/tabs_controller.js.coffee | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee diff --git a/app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee new file mode 100644 index 0000000000..4920834daf --- /dev/null +++ b/app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee @@ -0,0 +1,45 @@ +Darkswarm.controller "TabsCtrl", ($scope, $rootScope, $location) -> + $scope.active = (tab)-> + $location.path() == tab + + $scope.tabs = ["contact", "about", "groups", "producers"] + for tab in $scope.tabs + $scope[tab] = + active: false #$scope.active("/" + tab) + path: "/" + tab + + $scope.$watch -> + $location.path() + , (path)-> + for tab in $scope.tabs + $scope[tab].active = $scope.active($scope[tab].path) + + #$scope.select = (tab)-> + #$location.path tab.path + # + # + +# directive -> ng-click -> scope method (not isolated) -> toggle active | change location +# watch active expression -> change tab appearance + +#select = -> + #$location.path(tab.path) + +#active expression: + #"$location.path() == tab.path" + + +# directive -> ng-click -> set active (on isolated scope) +# ng-class -> change tab appearance +# two-way binding active attr <-> tab.active + +# directive attr (select) -> scope.selectExpression +# scope.select -> $parse ... +# +# in Directive +# scope.select = $parse(attrs.select) +# $scope.select($scope) +# +# 1: remove reverse binding on tab.active +# 2: put $parse(attrs.select) onto tab +# 3: override TabsetController/select to run tab.select() against original tab.$parent