Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit c9acebb

Browse files
chrisirhcpkozlowski-opensource
authored andcommittedDec 23, 2013
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 #783 Relates to #659
1 parent d6bf79b commit c9acebb

File tree

4 files changed

+8
-86
lines changed

4 files changed

+8
-86
lines changed
 

‎src/tabs/tabs.js

+4-30
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ angular.module('ui.bootstrap.tabs', [])
4848
* Tabset is the outer container for the tabs directive
4949
*
5050
* @param {boolean=} vertical Whether or not to use vertical styling for the tabs.
51-
* @param {string=} direction What direction the tabs should be rendered. Available:
52-
* 'right', 'left', 'below'.
5351
*
5452
* @example
5553
<example module="ui.bootstrap">
@@ -71,19 +69,12 @@ angular.module('ui.bootstrap.tabs', [])
7169
restrict: 'EA',
7270
transclude: true,
7371
replace: true,
74-
require: '^tabset',
7572
scope: {},
7673
controller: 'TabsetController',
7774
templateUrl: 'template/tabs/tabset.html',
78-
compile: function(elm, attrs, transclude) {
79-
return function(scope, element, attrs, tabsetCtrl) {
80-
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
81-
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
82-
scope.direction = angular.isDefined(attrs.direction) ? scope.$parent.$eval(attrs.direction) : 'top';
83-
scope.tabsAbove = (scope.direction != 'below');
84-
tabsetCtrl.$scope = scope;
85-
tabsetCtrl.$transcludeFn = transclude;
86-
};
75+
link: function(scope, element, attrs) {
76+
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
77+
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
8778
}
8879
};
8980
})
@@ -288,21 +279,4 @@ angular.module('ui.bootstrap.tabs', [])
288279
}
289280
})
290281

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

‎src/tabs/test/tabs.spec.js

+1-51
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() {
@@ -561,56 +561,6 @@ describe('tabs', function() {
561561
});
562562
});
563563

564-
describe('direction', function() {
565-
it('should not have `tab-left`, `tab-right` nor `tabs-below` classes if the direction is undefined', inject(function($compile, $rootScope) {
566-
scope = $rootScope.$new();
567-
scope.direction = undefined;
568-
569-
elm = $compile('<tabset direction="direction"></tabset>')(scope);
570-
scope.$apply();
571-
expect(elm).not.toHaveClass('tabs-left');
572-
expect(elm).not.toHaveClass('tabs-right');
573-
expect(elm).not.toHaveClass('tabs-below');
574-
expect(elm.find('.nav + .tab-content').length).toBe(1);
575-
}));
576-
577-
it('should only have the `tab-left` direction class if the direction is "left"', inject(function($compile, $rootScope) {
578-
scope = $rootScope.$new();
579-
scope.direction = 'left';
580-
581-
elm = $compile('<tabset direction="direction"></tabset>')(scope);
582-
scope.$apply();
583-
expect(elm).toHaveClass('tabs-left');
584-
expect(elm).not.toHaveClass('tabs-right');
585-
expect(elm).not.toHaveClass('tabs-below');
586-
expect(elm.find('.nav + .tab-content').length).toBe(1);
587-
}));
588-
589-
it('should only have the `tab-right direction class if the direction is "right"', inject(function($compile, $rootScope) {
590-
scope = $rootScope.$new();
591-
scope.direction = 'right';
592-
593-
elm = $compile('<tabset direction="direction"></tabset>')(scope);
594-
scope.$apply();
595-
expect(elm).not.toHaveClass('tabs-left');
596-
expect(elm).toHaveClass('tabs-right');
597-
expect(elm).not.toHaveClass('tabs-below');
598-
expect(elm.find('.nav + .tab-content').length).toBe(1);
599-
}));
600-
601-
it('should only have the `tab-below direction class if the direction is "below"', inject(function($compile, $rootScope) {
602-
scope = $rootScope.$new();
603-
scope.direction = 'below';
604-
605-
elm = $compile('<tabset direction="direction"></tabset>')(scope);
606-
scope.$apply();
607-
expect(elm).not.toHaveClass('tabs-left');
608-
expect(elm).not.toHaveClass('tabs-right');
609-
expect(elm).toHaveClass('tabs-below');
610-
expect(elm.find('.tab-content + .nav').length).toBe(1);
611-
}));
612-
});
613-
614564
//https://github.com/angular-ui/bootstrap/issues/524
615565
describe('child compilation', function() {
616566

‎template/tabs/tabset-titles.html

-2
This file was deleted.

‎template/tabs/tabset.html

+3-3
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)