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

Commit 3199dd8

Browse files
feat(tabs): add nav-justified
adds functionality for justifed tabs http://getbootstrap.com/components/#nav-justified
1 parent c141dac commit 3199dd8

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

src/tabs/docs/demo.html

+8
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@
2525
<tab heading="Vertical 1">Vertical content 1</tab>
2626
<tab heading="Vertical 2">Vertical content 2</tab>
2727
</tabset>
28+
29+
<hr />
30+
31+
<tabset justified="true">
32+
<tab heading="Justified">Justified content</tab>
33+
<tab heading="SJ">Short Labeled Justified content</tab>
34+
<tab heading="Long Justified">Long Labeled Justified content</tab>
35+
</tabset>
2836
</div>

src/tabs/docs/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ AngularJS version of the tabs directive.
88
_(Defaults: false)_ :
99
Whether tabs appear vertically stacked.
1010

11+
* `justified`
12+
_(Defaults: false)_ :
13+
Whether tabs fill the container and have a consistent width.
14+
1115
* `type`
1216
_(Defaults: 'tabs')_ :
1317
Navigation type. Possible values are 'tabs' and 'pills'.

src/tabs/tabs.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,24 @@ 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 {boolean=} justified Whether or not to use justified styling for the tabs.
5152
*
5253
* @example
5354
<example module="ui.bootstrap">
5455
<file name="index.html">
5556
<tabset>
56-
<tab heading="Vertical Tab 1"><b>First</b> Content!</tab>
57-
<tab heading="Vertical Tab 2"><i>Second</i> Content!</tab>
57+
<tab heading="Tab 1"><b>First</b> Content!</tab>
58+
<tab heading="Tab 2"><i>Second</i> Content!</tab>
5859
</tabset>
5960
<hr />
6061
<tabset vertical="true">
6162
<tab heading="Vertical Tab 1"><b>First</b> Vertical Content!</tab>
6263
<tab heading="Vertical Tab 2"><i>Second</i> Vertical Content!</tab>
6364
</tabset>
65+
<tabset justified="true">
66+
<tab heading="Justified Tab 1"><b>First</b> Justified Content!</tab>
67+
<tab heading="Justified Tab 2"><i>Second</i> Justified Content!</tab>
68+
</tabset>
6469
</file>
6570
</example>
6671
*/
@@ -74,6 +79,7 @@ angular.module('ui.bootstrap.tabs', [])
7479
templateUrl: 'template/tabs/tabset.html',
7580
link: function(scope, element, attrs) {
7681
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
82+
scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
7783
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
7884
}
7985
};

src/tabs/test/tabs.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,19 @@ describe('tabs', function() {
546546
});
547547
});
548548

549+
describe('justified', function() {
550+
beforeEach(inject(function($compile, $rootScope) {
551+
scope = $rootScope.$new();
552+
scope.justified = true;
553+
elm = $compile('<tabset justified="justified"></tabset>')(scope);
554+
scope.$apply();
555+
}));
556+
557+
it('to justify tabs', function() {
558+
expect(elm.find('ul.nav-tabs')).toHaveClass('nav-justified');
559+
});
560+
});
561+
549562
describe('type', function() {
550563
beforeEach(inject(function($compile, $rootScope) {
551564
scope = $rootScope.$new();

template/tabs/tabset.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
<div class="tabbable">
3-
<ul class="nav {{type && 'nav-' + type}}" ng-class="{'nav-stacked': vertical}" ng-transclude>
4-
</ul>
3+
<ul class="nav {{type && 'nav-' + type}}" ng-class="{'nav-stacked': vertical, 'nav-justified': justified}" ng-transclude></ul>
54
<div class="tab-content">
65
<div class="tab-pane"
76
ng-repeat="tab in tabs"

0 commit comments

Comments
 (0)