/
githubmirror
/
atom
Обзор
Документация
Войти
/
githubmirror
/
atom
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/title-bar.js
53 строки
2 KB
Rafael Oleza
Reformat all JS files using prettier
31 май 2019, 19:33
31 май 2019, 19:33
7f3f040
Код
Авторство
О чём код?
module.exports = class TitleBar { constructor({ workspace, themes, applicationDelegate }) { this.dblclickHandler = this.dblclickHandler.bind(this); this.workspace = workspace; this.themes = themes; this.applicationDelegate = applicationDelegate; this.element = document.createElement('div'); this.element.classList.add('title-bar'); this.titleElement = document.createElement('div'); this.titleElement.classList.add('title'); this.element.appendChild(this.titleElement); this.element.addEventListener('dblclick', this.dblclickHandler); this.workspace.onDidChangeWindowTitle(() => this.updateTitle()); this.themes.onDidChangeActiveThemes(() => this.updateWindowSheetOffset()); this.updateTitle(); this.updateWindowSheetOffset(); } dblclickHandler() { // User preference deciding which action to take on a title bar double-click switch ( this.applicationDelegate.getUserDefault( 'AppleActionOnDoubleClick', 'string' ) ) { case 'Minimize': this.applicationDelegate.minimizeWindow(); break; case 'Maximize': if (this.applicationDelegate.isWindowMaximized()) { this.applicationDelegate.unmaximizeWindow(); } else { this.applicationDelegate.maximizeWindow(); } break; } } updateTitle() { this.titleElement.textContent = document.title; } updateWindowSheetOffset() { this.applicationDelegate .getCurrentWindow() .setSheetOffset(this.element.offsetHeight); } };