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

Commit 53e0a39

Browse files
bekospkozlowski-opensource
authored andcommitted
feat(tabs): add support for other navigation types, like 'pills'
1 parent 497ba15 commit 53e0a39

File tree

6 files changed

+24
-2
lines changed

6 files changed

+24
-2
lines changed

src/tabs/docs/demo.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<hr />
2323

24-
<tabset vertical="true">
24+
<tabset vertical="true" type="navType">
2525
<tab heading="Vertical 1">Vertical content 1</tab>
2626
<tab heading="Vertical 2">Vertical content 2</tab>
2727
</tabset>

src/tabs/docs/demo.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ var TabsDemoCtrl = function ($scope) {
99
alert("You've selected the alert tab!");
1010
});
1111
};
12+
13+
$scope.navType = 'pills';
1214
};

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+
* `type`
12+
_(Defaults: 'tabs')_ :
13+
Navigation type. Possible values are 'tabs' and 'pills'.
14+
1115
#### `<tab>` ####
1216

1317
* `heading` or `<tab-heading>`

src/tabs/tabs.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function TabsetCtrl($scope, $element) {
4646
templateUrl: 'template/tabs/tabset.html',
4747
link: function(scope, element, attrs) {
4848
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$eval(attrs.vertical) : false;
49+
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
4950
}
5051
};
5152
})

src/tabs/test/tabsSpec.js

+15
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,19 @@ describe('tabs', function() {
460460
});
461461
});
462462

463+
describe('type', function() {
464+
beforeEach(inject(function($compile, $rootScope) {
465+
scope = $rootScope.$new();
466+
scope.navType = 'pills';
467+
468+
elm = $compile('<tabset type="navType"></tabset>')(scope);
469+
scope.$apply();
470+
}));
471+
472+
it('to show pills', function() {
473+
expect(elm.find('ul')).toHaveClass('nav-pills');
474+
expect(elm.find('ul')).not.toHaveClass('nav-tabs');
475+
});
476+
});
477+
463478
});

template/tabs/tabset.html

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

22
<div class="tabbable">
3-
<ul class="nav nav-tabs" ng-class="{'nav-stacked': vertical}" ng-transclude>
3+
<ul class="nav {{type && 'nav-' + type}}" ng-class="{'nav-stacked': vertical}" ng-transclude>
44
</ul>
55
<div class="tab-content">
66
<div class="tab-pane"

0 commit comments

Comments
 (0)