mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-24 08:33:36 +00:00
template() property used earlier in tab.ts was a property of its child classes, which causes problems in compiler, which this PR fixes.
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
'use strict';
|
|
|
|
import Tab = require('./tab');
|
|
|
|
class FunctionalTab extends Tab {
|
|
$closeButton: Element;
|
|
template(): string {
|
|
return `<div class="tab functional-tab" data-tab-id="${this.props.tabIndex}">
|
|
<div class="server-tab-badge close-button">
|
|
<i class="material-icons">close</i>
|
|
</div>
|
|
<div class="server-tab">
|
|
<i class="material-icons">${this.props.materialIcon}</i>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
|
|
// TODO: Typescript - This type for props should be TabProps
|
|
constructor(props: any) {
|
|
super(props);
|
|
this.init();
|
|
}
|
|
|
|
init(): void {
|
|
this.$el = this.generateNodeFromTemplate(this.template());
|
|
if (this.props.name !== 'Settings') {
|
|
this.props.$root.append(this.$el);
|
|
this.$closeButton = this.$el.querySelectorAll('.server-tab-badge')[0];
|
|
this.registerListeners();
|
|
}
|
|
}
|
|
|
|
registerListeners(): void {
|
|
super.registerListeners();
|
|
|
|
this.$el.addEventListener('mouseover', () => {
|
|
this.$closeButton.classList.add('active');
|
|
});
|
|
|
|
this.$el.addEventListener('mouseout', () => {
|
|
this.$closeButton.classList.remove('active');
|
|
});
|
|
|
|
this.$closeButton.addEventListener('click', (e: Event) => {
|
|
this.props.onDestroy();
|
|
e.stopPropagation();
|
|
});
|
|
}
|
|
}
|
|
|
|
export = FunctionalTab;
|