Make tabs auto-close on mobile

This commit is contained in:
Joseph Schorr 2015-04-21 15:09:52 -04:00
parent 765492e882
commit 48a8a8e65c

View file

@ -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;