34 lines
877 B
JavaScript
34 lines
877 B
JavaScript
class Window {
|
|
constructor(id) {
|
|
this.container = document.getElementById(`${id}-container`)
|
|
this.innerContainer = document.getElementById(id)
|
|
}
|
|
|
|
show(fromTerminal=false) {
|
|
this.resize()
|
|
this.container.style.display = 'block'
|
|
var self = this;
|
|
document.addEventListener('keydown', function(event) {
|
|
if (event.key === 'Escape') {
|
|
self.hide()
|
|
if (fromTerminal) {
|
|
terminal.show()
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
hide() {
|
|
this.container.style.display = 'none'
|
|
this.handleDialog();
|
|
}
|
|
|
|
handleDialog(){}
|
|
|
|
resize() {
|
|
this.container.style.width = canvas.getBoundingClientRect().width - 40 + 'px';
|
|
this.container.style.height = canvas.getBoundingClientRect().height - 40 + 'px';
|
|
this.container.style.minHeight = canvas.getBoundingClientRect().width - 40 + 'px';
|
|
this.innerContainer.style.height = canvas.getBoundingClientRect().height - 77 + 'px';
|
|
}
|
|
}
|