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

Commit c6197ed

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

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

src/tabs/docs/demo.html

Lines changed: 8 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,26 @@ function TabsetCtrl($scope, $element) {
5656
* Tabset is the outer container for the tabs directive
5757
*
5858
* @param {boolean=} vertical Whether or not to use vertical styling for the tabs.
59+
* @param {boolean=} justified Whether or not to use justified styling for the tabs.
5960
* @param {string=} direction What direction the tabs should be rendered. Available:
6061
* 'right', 'left', 'below'.
6162
*
6263
* @example
6364
<example module="ui.bootstrap">
6465
<file name="index.html">
6566
<tabset>
66-
<tab heading="Vertical Tab 1"><b>First</b> Content!</tab>
67-
<tab heading="Vertical Tab 2"><i>Second</i> Content!</tab>
67+
<tab heading="Tab 1"><b>First</b> Content!</tab>
68+
<tab heading="Tab 2"><i>Second</i> Content!</tab>
6869
</tabset>
6970
<hr />
7071
<tabset vertical="true">
7172
<tab heading="Vertical Tab 1"><b>First</b> Vertical Content!</tab>
7273
<tab heading="Vertical Tab 2"><i>Second</i> Vertical Content!</tab>
7374
</tabset>
75+
<tabset justified="true">
76+
<tab heading="Justified Tab 1"><b>First</b> Justified Content!</tab>
77+
<tab heading="Justified Tab 2"><i>Second</i> Justified Content!</tab>
78+
</tabset>
7479
</file>
7580
</example>
7681
*/
@@ -86,6 +91,7 @@ function TabsetCtrl($scope, $element) {
8691
compile: function(elm, attrs, transclude) {
8792
return function(scope, element, attrs, tabsetCtrl) {
8893
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
94+
scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
8995
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
9096
scope.direction = angular.isDefined(attrs.direction) ? scope.$parent.$eval(attrs.direction) : 'top';
9197
scope.tabsAbove = (scope.direction != 'below');

src/tabs/test/tabsSpec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,19 @@ describe('tabs', function() {
478478
});
479479
});
480480

481+
describe('justified', function() {
482+
beforeEach(inject(function($compile, $rootScope) {
483+
scope = $rootScope.$new();
484+
scope.justified = true;
485+
elm = $compile('<tabset justified="justified"></tabset>')(scope);
486+
scope.$apply();
487+
}));
488+
489+
it('to justify tabs', function() {
490+
expect(elm.find('ul.nav-tabs')).toHaveClass('nav-justified');
491+
});
492+
});
493+
481494
describe('type', function() {
482495
beforeEach(inject(function($compile, $rootScope) {
483496
scope = $rootScope.$new();

template/tabs/tabset-titles.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<ul class="nav {{type && 'nav-' + type}}" ng-class="{'nav-stacked': vertical}">
1+
<ul class="nav {{type && 'nav-' + type}}" ng-class="{'nav-stacked': vertical, 'nav-justified': justified}">
22
</ul>

0 commit comments

Comments
 (0)