From 48a8a8e65c9b1d52c031b8a4df49efdcd2234bb7 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 21 Apr 2015 15:09:52 -0400 Subject: [PATCH] Make tabs auto-close on mobile --- static/js/core-ui.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/static/js/core-ui.js b/static/js/core-ui.js index 1f09b087c..0f27bdd7a 100644 --- a/static/js/core-ui.js +++ b/static/js/core-ui.js @@ -243,7 +243,7 @@ angular.module("core-ui", []) transclude: true, restrict: 'C', scope: {}, - controller: function($rootScope, $scope, $element) { + controller: function($rootScope, $scope, $element, $timeout) { $scope.isClosed = true; $scope.toggleClosed = function(e) { @@ -251,6 +251,14 @@ angular.module("core-ui", []) e.stopPropagation(); e.preventDefault(); }; + + // Add a listener to auto-close the tabs when a new tab is clicked. + $timeout(function() { + var tabs = $element.find('a[data-toggle="tab"]'); + tabs.on('shown.bs.tab', function (e) { + $scope.isClosed = true; + }); + }, 100); } }; return directiveDefinitionObject;