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;
|
|
|
|
|
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({
|
|
|
|
tabsManager: computed(function () {
|
2014-09-15 04:40:24 +04:00
|
|
|
return this.nearestWithProperty('isTabsManager');
|
|
|
|
}),
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
active: computed('tabsManager.activeTab', function () {
|
2014-09-15 04:40:24 +04:00
|
|
|
return this.get('tabsManager.activeTab') === this;
|
|
|
|
}),
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
index: computed('tabsManager.tabs.[]', function () {
|
2014-09-15 04:40:24 +04:00
|
|
|
return this.get('tabsManager.tabs').indexOf(this);
|
|
|
|
}),
|
|
|
|
|
|
|
|
// Select on click
|
2015-10-28 14:36:45 +03:00
|
|
|
click() {
|
2014-09-15 04:40:24 +04:00
|
|
|
this.get('tabsManager').select(this);
|
|
|
|
},
|
|
|
|
|
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 the tabs with the tab manager
|
2014-09-15 04:40:24 +04:00
|
|
|
this.get('tabsManager').registerTab(this);
|
2015-06-03 05:56:42 +03:00
|
|
|
},
|
2014-09-15 04:40:24 +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
|
|
|
// unregister the tabs with the tab manager
|
2014-09-15 04:40:24 +04:00
|
|
|
this.get('tabsManager').unregisterTab(this);
|
2015-06-03 05:56:42 +03:00
|
|
|
}
|
2014-09-15 04:40:24 +04:00
|
|
|
});
|