From 48c667d2dd9ee3ffbd7336b69dc299988d9957dc Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 27 Jan 2021 10:25:05 +0100 Subject: [PATCH] add onLocationChangeSuccess event handler watch this event and toggle class if needed. --- .../darkswarm/directives/tabset_ctrl.js.coffee | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/tabset_ctrl.js.coffee b/app/assets/javascripts/darkswarm/directives/tabset_ctrl.js.coffee index dd8d9a279b..4587a7cca4 100644 --- a/app/assets/javascripts/darkswarm/directives/tabset_ctrl.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/tabset_ctrl.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "tabsetCtrl", (Tabsets, $location) -> +Darkswarm.directive "tabsetCtrl", (Tabsets, $location, $rootScope) -> restrict: "C" scope: id: "@" @@ -9,7 +9,13 @@ Darkswarm.directive "tabsetCtrl", (Tabsets, $location) -> if $scope.navigate path = $location.path()?.match(/^\/\w+$/)?[0] $scope.selected = path[1..] if path - + + # Watch location change success event to operate back/forward buttons + $rootScope.$on "$locationChangeSuccess", -> + if $scope.navigate + path = $location.path()?.match(/^\/\w+$/)?[0] + Tabsets.toggle($scope.id, path[1..] if path) + this.toggle = (name) -> Tabsets.toggle($scope.id, name)