2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2015-08-19 12:55:40 +01:00
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
const {Component, computed} = Ember;
|
|
|
|
const {alias} = computed;
|
|
|
|
|
2014-10-24 21:09:50 +00:00
|
|
|
// See gh-tabs-manager.js for use
|
2015-10-28 11:36:45 +00:00
|
|
|
export default Component.extend({
|
2014-09-14 18:40:24 -06:00
|
|
|
classNameBindings: ['active'],
|
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
tabsManager: computed(function () {
|
2014-09-14 18:40:24 -06:00
|
|
|
return this.nearestWithProperty('isTabsManager');
|
|
|
|
}),
|
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
tab: computed('tabsManager.tabs.[]', 'tabsManager.tabPanes.[]', function () {
|
|
|
|
let index = this.get('tabsManager.tabPanes').indexOf(this);
|
|
|
|
let tabs = this.get('tabsManager.tabs');
|
2014-09-14 18:40:24 -06:00
|
|
|
|
|
|
|
return tabs && tabs.objectAt(index);
|
|
|
|
}),
|
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
active: alias('tab.active'),
|
2014-09-14 18:40:24 -06:00
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
willRender() {
|
2015-06-02 20:56:42 -06:00
|
|
|
// Register with the tabs manager
|
2014-09-14 18:40:24 -06:00
|
|
|
this.get('tabsManager').registerTabPane(this);
|
2015-06-02 20:56:42 -06:00
|
|
|
},
|
2014-10-24 21:09:50 +00:00
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
willDestroyElement() {
|
2015-06-02 20:56:42 -06:00
|
|
|
// Deregister with the tabs manager
|
2014-09-14 18:40:24 -06:00
|
|
|
this.get('tabsManager').unregisterTabPane(this);
|
2015-06-02 20:56:42 -06:00
|
|
|
}
|
2014-09-14 18:40:24 -06:00
|
|
|
});
|