Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2018-08-03 16:15:04 +0300
committerFilipa Lacerda <filipa@gitlab.com>2018-08-03 17:16:39 +0300
commit26b8209ecdef4bb8c94b7fa3aa2fca7281de5e2b (patch)
tree51787ad3908a72e52dac47e0240042b82d1eafec /app/assets/javascripts/terminal
parent0116930bb0ae30bcb7b43b87371f1418e74661f1 (diff)
Focus terminal on load
Use object.assign for default option
Diffstat (limited to 'app/assets/javascripts/terminal')
-rw-r--r--app/assets/javascripts/terminal/terminal.js19
1 files changed, 6 insertions, 13 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();