Ghost/core/client/app/components/gh-tab-pane.js

35 lines
923 B
JavaScript
Raw Normal View History

2015-02-13 07:22:32 +03:00
import Ember from 'ember';
const {Component, computed} = Ember;
const {alias} = 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);
}
});