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