diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-08-03 16:15:04 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-08-03 17:16:39 +0300 |
commit | 26b8209ecdef4bb8c94b7fa3aa2fca7281de5e2b (patch) | |
tree | 51787ad3908a72e52dac47e0240042b82d1eafec /app | |
parent | 0116930bb0ae30bcb7b43b87371f1418e74661f1 (diff) |
Focus terminal on load
Use object.assign for default option
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/terminal/terminal.js | 19 | ||||
-rw-r--r-- | app/assets/stylesheets/application.scss | 1 |
2 files changed, 6 insertions, 14 deletions
diff --git a/app/assets/javascripts/terminal/terminal.js b/app/assets/javascripts/terminal/terminal.js index 8a94c9f4fe1..74c5bbe45a4 100644 --- a/app/assets/javascripts/terminal/terminal.js +++ b/app/assets/javascripts/terminal/terminal.js @@ -1,19 +1,13 @@ import $ from 'jquery'; import { Terminal } from 'xterm'; import * as fit from 'xterm/lib/addons/fit/fit'; -import * as attach from 'xterm/lib/addons/attach/attach'; export default class GLTerminal { - constructor(options) { - this.options = options || {}; - - if (!Object.prototype.hasOwnProperty.call(this.options, 'cursorBlink')) { - this.options.cursorBlink = true; - } - - if (!Object.prototype.hasOwnProperty.call(this.options, 'screenKeys')) { - this.options.screenKeys = true; - } + constructor(options = {}) { + this.options = Object.assign({}, { + cursorBlink: true, + screenKeys: true, + }, options); this.container = document.querySelector(options.selector); @@ -37,16 +31,15 @@ export default class GLTerminal { createTerminal() { Terminal.applyAddon(fit); - Terminal.applyAddon(attach); this.terminal = new Terminal(this.options); - //TODO - CHECK IF WE SHOULD USE `attach` instead this.socket = new WebSocket(this.socketUrl, ['terminal.gitlab.com']); this.socket.binaryType = 'arraybuffer'; this.terminal.open(this.container); this.terminal.fit(); + this.terminal.focus(); this.socket.onopen = () => { this.runTerminal(); diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index ebc7e0e8106..f2950308019 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -19,7 +19,6 @@ @import "../../../node_modules/pikaday/scss/pikaday"; - /* * GitLab UI framework */ |