mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-03 21:43:18 +00:00 
			
		
		
		
	typescript: Migrate functional-tab.js to typescript.
This commit is contained in:
		@@ -1,9 +1,10 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const Tab = require(__dirname + '/../components/tab.js');
 | 
					import Tab = require('./tab');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class FunctionalTab extends Tab {
 | 
					class FunctionalTab extends Tab {
 | 
				
			||||||
	template() {
 | 
						$closeButton: Element;
 | 
				
			||||||
 | 
						template(): string {
 | 
				
			||||||
		return `<div class="tab functional-tab" data-tab-id="${this.props.tabIndex}">
 | 
							return `<div class="tab functional-tab" data-tab-id="${this.props.tabIndex}">
 | 
				
			||||||
					<div class="server-tab-badge close-button">
 | 
										<div class="server-tab-badge close-button">
 | 
				
			||||||
						<i class="material-icons">close</i>
 | 
											<i class="material-icons">close</i>
 | 
				
			||||||
@@ -14,16 +15,16 @@ class FunctionalTab extends Tab {
 | 
				
			|||||||
				</div>`;
 | 
									</div>`;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	init() {
 | 
						init(): void {
 | 
				
			||||||
		this.$el = this.generateNodeFromTemplate(this.template());
 | 
							this.$el = this.generateNodeFromTemplate(this.template());
 | 
				
			||||||
		if (this.props.name !== 'Settings') {
 | 
							if (this.props.name !== 'Settings') {
 | 
				
			||||||
			this.props.$root.appendChild(this.$el);
 | 
								this.props.$root.append(this.$el);
 | 
				
			||||||
			this.$closeButton = this.$el.getElementsByClassName('server-tab-badge')[0];
 | 
								this.$closeButton = this.$el.querySelectorAll('.server-tab-badge')[0];
 | 
				
			||||||
			this.registerListeners();
 | 
								this.registerListeners();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	registerListeners() {
 | 
						registerListeners(): void {
 | 
				
			||||||
		super.registerListeners();
 | 
							super.registerListeners();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.$el.addEventListener('mouseover', () => {
 | 
							this.$el.addEventListener('mouseover', () => {
 | 
				
			||||||
@@ -34,11 +35,11 @@ class FunctionalTab extends Tab {
 | 
				
			|||||||
			this.$closeButton.classList.remove('active');
 | 
								this.$closeButton.classList.remove('active');
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.$closeButton.addEventListener('click', e => {
 | 
							this.$closeButton.addEventListener('click', (e: Event) => {
 | 
				
			||||||
			this.props.onDestroy();
 | 
								this.props.onDestroy();
 | 
				
			||||||
			e.stopPropagation();
 | 
								e.stopPropagation();
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = FunctionalTab;
 | 
					export = FunctionalTab;
 | 
				
			||||||
		Reference in New Issue
	
	Block a user