mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-19 23:17:16 +03:00
Convert src/title-bar.coffee to js
Signed-off-by: Jason Rudolph <jasonrudolph@github.com>
This commit is contained in:
parent
a7b1996245
commit
9e8f07b926
@ -1,34 +0,0 @@
|
||||
module.exports =
|
||||
class TitleBar
|
||||
constructor: ({@workspace, @themes, @applicationDelegate}) ->
|
||||
@element = document.createElement('div')
|
||||
@element.classList.add('title-bar')
|
||||
|
||||
@titleElement = document.createElement('div')
|
||||
@titleElement.classList.add('title')
|
||||
@element.appendChild(@titleElement)
|
||||
|
||||
@element.addEventListener 'dblclick', @dblclickHandler
|
||||
|
||||
@workspace.onDidChangeWindowTitle => @updateTitle()
|
||||
@themes.onDidChangeActiveThemes => @updateWindowSheetOffset()
|
||||
|
||||
@updateTitle()
|
||||
@updateWindowSheetOffset()
|
||||
|
||||
dblclickHandler: =>
|
||||
# User preference deciding which action to take on a title bar double-click
|
||||
switch @applicationDelegate.getUserDefault('AppleActionOnDoubleClick', 'string')
|
||||
when 'Minimize'
|
||||
@applicationDelegate.minimizeWindow()
|
||||
when 'Maximize'
|
||||
if @applicationDelegate.isWindowMaximized()
|
||||
@applicationDelegate.unmaximizeWindow()
|
||||
else
|
||||
@applicationDelegate.maximizeWindow()
|
||||
|
||||
updateTitle: ->
|
||||
@titleElement.textContent = document.title
|
||||
|
||||
updateWindowSheetOffset: ->
|
||||
@applicationDelegate.getCurrentWindow().setSheetOffset(@element.offsetHeight)
|
47
src/title-bar.js
Normal file
47
src/title-bar.js
Normal file
@ -0,0 +1,47 @@
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user