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

Commit

Permalink
feat(tabs): add support for vertical option
Browse files Browse the repository at this point in the history
  • Loading branch information
bekos authored and ajoslin committed May 30, 2013
1 parent c2e8d38 commit 88d17a7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/tabs/docs/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@
I've got an HTML heading, and a select callback. Pretty cool!
</tab>
</tabset>

<hr />

<tabset vertical="true">
<tab heading="Vertical 1">Vertical content 1</tab>
<tab heading="Vertical 2">Vertical content 2</tab>
</tabset>
</div>
26 changes: 24 additions & 2 deletions src/tabs/docs/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
AngularJS version of the tabs directive.

Allows a `select` callback attribute, `active` binding attribute and `disabled` binding attribute.
### Settings ###

Allows either `heading` text-heading as an attribute, or a `<tab-heading>` element inside as the heading.
#### `<tabset>` ####

* `vertical`
_(Defaults: false)_ :
Whether tabs appear vertically stacked.

#### `<tab>` ####

* `heading` or `<tab-heading>`
:
Heading text or HTML markup.

* `active` <i class="icon-eye-open"></i>
_(Defaults: false)_ :
Whether tab is currently selected.

* `disabled` <i class="icon-eye-open"></i>
_(Defaults: false)_ :
Whether tab is clickable and can be activated.

* `select()`
_(Defaults: null)_ :
An optional expression called when tab is activated.
5 changes: 4 additions & 1 deletion src/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ function TabsetCtrl($scope, $element) {
transclude: true,
scope: {},
controller: 'TabsetController',
templateUrl: 'template/tabs/tabset.html'
templateUrl: 'template/tabs/tabset.html',
link: function(scope, element, attrs) {
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$eval(attrs.vertical) : false;
}
};
})

Expand Down
20 changes: 13 additions & 7 deletions src/tabs/test/tabsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,6 @@ describe('tabs', function() {
scope.$apply();
}));

function titles() {
return elm.find('ul.nav-tabs li');
}
function contents() {
return elm.find('div.tab-content div.tab-pane');
}

function expectTabActive(activeTab) {
var _titles = titles();
angular.forEach(scope.tabs, function(tab, i) {
Expand Down Expand Up @@ -454,4 +447,17 @@ describe('tabs', function() {
});
});

describe('vertical', function() {
beforeEach(inject(function($compile, $rootScope) {
scope = $rootScope.$new();

elm = $compile('<tabset vertical="true"></tabset>')(scope);
scope.$apply();
}));

it('to stack tabs', function() {
expect(elm.find('ul.nav-tabs')).toHaveClass('nav-stacked');
});
});

});
2 changes: 1 addition & 1 deletion template/tabs/tabset.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<div class="tabbable">
<ul class="nav nav-tabs" ng-transclude>
<ul class="nav nav-tabs" ng-class="{'nav-stacked': vertical}" ng-transclude>
</ul>
<div class="tab-content">
<div class="tab-pane"
Expand Down

0 comments on commit 88d17a7

Please sign in to comment.