Skip to content

Commit 76e3c5d

Browse files
committed
fix(tabs): make nested tabs work
This reverts commit 220e7b6. Revert the capability to set the tab direction. This is no longer a feature in Bootstrap 3 and breaks nested tabs. Closes angular-ui#783 Relates to angular-ui#659
1 parent 3e010d4 commit 76e3c5d

File tree

4 files changed

+8
-86
lines changed

4 files changed

+8
-86
lines changed

src/tabs/tabs.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ angular.module('ui.bootstrap.tabs', [])
5454
* Tabset is the outer container for the tabs directive
5555
*
5656
* @param {boolean=} vertical Whether or not to use vertical styling for the tabs.
57-
* @param {string=} direction What direction the tabs should be rendered. Available:
58-
* 'right', 'left', 'below'.
5957
*
6058
* @example
6159
<example module="ui.bootstrap">
@@ -77,19 +75,12 @@ angular.module('ui.bootstrap.tabs', [])
7775
restrict: 'EA',
7876
transclude: true,
7977
replace: true,
80-
require: '^tabset',
8178
scope: {},
8279
controller: 'TabsetController',
8380
templateUrl: 'template/tabs/tabset.html',
84-
compile: function(elm, attrs, transclude) {
85-
return function(scope, element, attrs, tabsetCtrl) {
86-
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
87-
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
88-
scope.direction = angular.isDefined(attrs.direction) ? scope.$parent.$eval(attrs.direction) : 'top';
89-
scope.tabsAbove = (scope.direction != 'below');
90-
tabsetCtrl.$scope = scope;
91-
tabsetCtrl.$transcludeFn = transclude;
92-
};
81+
link: function(scope, element, attrs) {
82+
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
83+
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
9384
}
9485
};
9586
})
@@ -294,21 +285,4 @@ angular.module('ui.bootstrap.tabs', [])
294285
}
295286
})
296287

297-
.directive('tabsetTitles', function() {
298-
return {
299-
restrict: 'A',
300-
require: '^tabset',
301-
templateUrl: 'template/tabs/tabset-titles.html',
302-
replace: true,
303-
link: function(scope, elm, attrs, tabsetCtrl) {
304-
if (!scope.$eval(attrs.tabsetTitles)) {
305-
elm.remove();
306-
} else {
307-
//now that tabs location has been decided, transclude the tab titles in
308-
tabsetCtrl.$transcludeFn(tabsetCtrl.$scope.$parent, function(node) {
309-
elm.append(node);
310-
});
311-
}
312-
}
313-
};
314-
});
288+
;

src/tabs/test/tabs.spec.js

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
describe('tabs', function() {
2-
beforeEach(module('ui.bootstrap.tabs', 'template/tabs/tabset.html', 'template/tabs/tab.html', 'template/tabs/tabset-titles.html'));
2+
beforeEach(module('ui.bootstrap.tabs', 'template/tabs/tabset.html', 'template/tabs/tab.html'));
33

44
var elm, scope;
55
function titles() {
@@ -544,56 +544,6 @@ describe('tabs', function() {
544544
});
545545
});
546546

547-
describe('direction', function() {
548-
it('should not have `tab-left`, `tab-right` nor `tabs-below` classes if the direction is undefined', inject(function($compile, $rootScope) {
549-
scope = $rootScope.$new();
550-
scope.direction = undefined;
551-
552-
elm = $compile('<tabset direction="direction"></tabset>')(scope);
553-
scope.$apply();
554-
expect(elm).not.toHaveClass('tabs-left');
555-
expect(elm).not.toHaveClass('tabs-right');
556-
expect(elm).not.toHaveClass('tabs-below');
557-
expect(elm.find('.nav + .tab-content').length).toBe(1);
558-
}));
559-
560-
it('should only have the `tab-left` direction class if the direction is "left"', inject(function($compile, $rootScope) {
561-
scope = $rootScope.$new();
562-
scope.direction = 'left';
563-
564-
elm = $compile('<tabset direction="direction"></tabset>')(scope);
565-
scope.$apply();
566-
expect(elm).toHaveClass('tabs-left');
567-
expect(elm).not.toHaveClass('tabs-right');
568-
expect(elm).not.toHaveClass('tabs-below');
569-
expect(elm.find('.nav + .tab-content').length).toBe(1);
570-
}));
571-
572-
it('should only have the `tab-right direction class if the direction is "right"', inject(function($compile, $rootScope) {
573-
scope = $rootScope.$new();
574-
scope.direction = 'right';
575-
576-
elm = $compile('<tabset direction="direction"></tabset>')(scope);
577-
scope.$apply();
578-
expect(elm).not.toHaveClass('tabs-left');
579-
expect(elm).toHaveClass('tabs-right');
580-
expect(elm).not.toHaveClass('tabs-below');
581-
expect(elm.find('.nav + .tab-content').length).toBe(1);
582-
}));
583-
584-
it('should only have the `tab-below direction class if the direction is "below"', inject(function($compile, $rootScope) {
585-
scope = $rootScope.$new();
586-
scope.direction = 'below';
587-
588-
elm = $compile('<tabset direction="direction"></tabset>')(scope);
589-
scope.$apply();
590-
expect(elm).not.toHaveClass('tabs-left');
591-
expect(elm).not.toHaveClass('tabs-right');
592-
expect(elm).toHaveClass('tabs-below');
593-
expect(elm.find('.tab-content + .nav').length).toBe(1);
594-
}));
595-
});
596-
597547
//https://github.com/angular-ui/bootstrap/issues/524
598548
describe('child compilation', function() {
599549

template/tabs/tabset-titles.html

Lines changed: 0 additions & 2 deletions
This file was deleted.

template/tabs/tabset.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

2-
<div class="tabbable" ng-class="{'tabs-right': direction == 'right', 'tabs-left': direction == 'left', 'tabs-below': direction == 'below'}">
3-
<div tabset-titles="tabsAbove"></div>
2+
<div class="tabbable">
3+
<ul class="nav {{type && 'nav-' + type}}" ng-class="{'nav-stacked': vertical}" ng-transclude>
4+
</ul>
45
<div class="tab-content">
56
<div class="tab-pane"
67
ng-repeat="tab in tabs"
78
ng-class="{active: tab.active}"
89
tab-content-transclude="tab">
910
</div>
1011
</div>
11-
<div tabset-titles="!tabsAbove"></div>
1212
</div>

0 commit comments

Comments
 (0)