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