2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2014-10-24 21:09:50 +00:00
|
|
|
// See gh-tabs-manager.js for use
|
2014-09-14 18:40:24 -06:00
|
|
|
var Tab = Ember.Component.extend({
|
|
|
|
tabsManager: Ember.computed(function () {
|
|
|
|
return this.nearestWithProperty('isTabsManager');
|
|
|
|
}),
|
|
|
|
|
|
|
|
active: Ember.computed('tabsManager.activeTab', function () {
|
|
|
|
return this.get('tabsManager.activeTab') === this;
|
|
|
|
}),
|
|
|
|
|
|
|
|
index: Ember.computed('tabsManager.tabs.@each', function () {
|
|
|
|
return this.get('tabsManager.tabs').indexOf(this);
|
|
|
|
}),
|
|
|
|
|
|
|
|
// Select on click
|
|
|
|
click: function () {
|
|
|
|
this.get('tabsManager').select(this);
|
|
|
|
},
|
|
|
|
|
2015-06-02 20:56:42 -06:00
|
|
|
didInsertElement: function () {
|
|
|
|
// register the tabs with the tab manager
|
2014-09-14 18:40:24 -06:00
|
|
|
this.get('tabsManager').registerTab(this);
|
2015-06-02 20:56:42 -06:00
|
|
|
},
|
2014-09-14 18:40:24 -06:00
|
|
|
|
2015-06-02 20:56:42 -06:00
|
|
|
willDestroyElement: function () {
|
|
|
|
// unregister the tabs with the tab manager
|
2014-09-14 18:40:24 -06:00
|
|
|
this.get('tabsManager').unregisterTab(this);
|
2015-06-02 20:56:42 -06:00
|
|
|
}
|
2014-09-14 18:40:24 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
export default Tab;
|