Bläddra i källkod

Fix a bug that prevented the terminal from recovering the focus when it was hidden while awaiting input

Lucas de Souza 5 år sedan
förälder
incheckning
fdf74054da
1 ändrade filer med 18 tillägg och 9 borttagningar
  1. 18 9
      js/io/domConsole.js

+ 18 - 9
js/io/domConsole.js

@@ -62,6 +62,7 @@ export class DOMConsole {
     this.setup();
     this.inputListeners = [];
     this.hideInput();
+    this.was_waiting_input = false;
   }
 
   setup () {
@@ -120,14 +121,14 @@ export class DOMConsole {
     this.showBtn = bashNode.querySelector('#ivprog-console-showbtn');
     this._setupCursor();
     //Jquery tooltips....
-    $(this.clearBtn).popup({content:LocalizedStrings.getUI("tooltip_terminal_clear")});
-    $(this.showBtn).popup({content:LocalizedStrings.getUI("tooltip_terminal_show")});
-    $(this.hideBtn).popup({content:LocalizedStrings.getUI("tooltip_terminal_hide")});
+    window.$(this.clearBtn).popup({content:LocalizedStrings.getUI("tooltip_terminal_clear")});
+    window.$(this.showBtn).popup({content:LocalizedStrings.getUI("tooltip_terminal_show")});
+    window.$(this.hideBtn).popup({content:LocalizedStrings.getUI("tooltip_terminal_hide")});
   }
 
   _setupCursor () {
     this.inputCMD.addEventListener('click', this.blinkCaretAndFocus.bind(this));
-    this.inputCMD.click();
+    //this.inputCMD.click();
     
     this.input.addEventListener('keyup', this.updateSpanText.bind(this));
     this.input.addEventListener('blur', this.stopBlinkCaret.bind(this));
@@ -138,12 +139,12 @@ export class DOMConsole {
       return;
     }
     this.input.focus();
-    const outerRef = this;
+    const that = this;
     this.cursorInterval = window.setInterval(function() {
-      if (outerRef.cursorRef.style.visibility === 'visible') {
-        outerRef.cursorRef.style.visibility = 'hidden';
+      if (that.cursorRef.style.visibility === 'visible') {
+        that.cursorRef.style.visibility = 'hidden';
       } else {
-        outerRef.cursorRef.style.visibility = 'visible';
+        that.cursorRef.style.visibility = 'visible';
       }
     }, 500);
   }
@@ -223,18 +224,26 @@ export class DOMConsole {
     if(!this.disableMarginTop && this.parent.style.top.length == 0) {
       this.parent.style.marginTop = "-160px";
     }
+    if(this.needInput) {
+      this.showInput();
+      this.scheduleNotify();
+    }
     if(!isElementInViewport(this.termDiv))
       this.termDiv.scrollIntoView(false);
     this.scrollTerm();
   }
 
   hide () {
+    if(this.needInput) {
+      clearInterval(this.idleInterval);
+      this.hideInput();
+      this.needInput = true;
+    }
     // Is in draggable mode?
     if(!this.disableMarginTop && this.parent.style.top.length == 0) {
       this.parent.style.marginTop = "0";
     }
     this.termDiv.style.display = 'none';
-    
   }
 
   getClassForType (type) {