1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/gh-tab-pane.js
Austin Burdine 2dff7edd3d convert remainder of components to use ember-cli-shims (#101)
follow up from #95
- converts components to use ember-cli-shims
2016-06-30 19:14:25 +01:00

32 lines
921 B
JavaScript

import Component from 'ember-component';
import computed, {alias} from 'ember-computed';
// See gh-tabs-manager.js for use
export default Component.extend({
classNameBindings: ['active'],
tabsManager: computed(function () {
return this.nearestWithProperty('isTabsManager');
}),
tab: computed('tabsManager.tabs.[]', 'tabsManager.tabPanes.[]', function () {
let index = this.get('tabsManager.tabPanes').indexOf(this);
let tabs = this.get('tabsManager.tabs');
return tabs && tabs.objectAt(index);
}),
active: alias('tab.active'),
willRender() {
this._super(...arguments);
// Register with the tabs manager
this.get('tabsManager').registerTabPane(this);
},
willDestroyElement() {
this._super(...arguments);
// Deregister with the tabs manager
this.get('tabsManager').unregisterTabPane(this);
}
});