Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions app/scripts/controllers/pod.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,33 @@ angular.module('openshiftConsole')

var characterBoundingBox = calculateCharacterBoundingBox();
var win = $( window );
var calculateTerminalSize = function(){
if (!characterBoundingBox.height || !characterBoundingBox.width) {
var calculateTerminalSize = function(retries){
if (!retries) {
retries = 0;
}

if (!characterBoundingBox.height || !characterBoundingBox.width || !$scope.selectedTab.terminal || retries > 10) {
return;
}
$scope.$apply(function() {
var terminalWrapper = $('.container-terminal-wrapper').get(0);
// `terminalWrapper` won't exist until the user selects the terminal tab.
// `terminalWrapper` may not exist yet, we should retry
if (!terminalWrapper) {
$timeout(function(){
calculateTerminalSize(retries + 1);
}, 50);
return;
}

var r = terminalWrapper.getBoundingClientRect();
// Check if the content under the terminal tab isnt fully appended to the DOM yet, in that case
// there is no bounding box yet so we can't calculate the right width / height. Retry.
if (r.left === 0 && r.top === 0 && r.width === 0 && r.height === 0) {
$timeout(function(){
calculateTerminalSize(retries + 1);
}, 50);
return;
}
var windowWidth = win.width();
var windowHeight = win.height();
var termWidth = windowWidth - r.left - 40; // we want 40px right padding, includes 20px padding within the container terminal
Expand Down
19 changes: 12 additions & 7 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4406,13 +4406,18 @@ width:a.width() / 10,
height:a.height()
};
return a.remove(), b;
}, r = q(), s = $(window), t = function() {
r.height && r.width && a.$apply(function() {
var b = $(".container-terminal-wrapper").get(0);
if (b) {
var c = b.getBoundingClientRect(), d = s.width(), e = s.height(), f = d - c.left - 40, g = e - c.top - 50;
a.terminalCols = Math.max(_.floor(f / r.width), 80), a.terminalRows = Math.max(_.floor(g / r.height), 24);
}
}, r = q(), s = $(window), t = function(b) {
b || (b = 0), r.height && r.width && a.selectedTab.terminal && !(b > 10) && a.$apply(function() {
var c = $(".container-terminal-wrapper").get(0);
if (!c) return void d(function() {
t(b + 1);
}, 50);
var e = c.getBoundingClientRect();
if (0 === e.left && 0 === e.top && 0 === e.width && 0 === e.height) return void d(function() {
t(b + 1);
}, 50);
var f = s.width(), g = s.height(), h = f - e.left - 40, i = g - e.top - 50;
a.terminalCols = Math.max(_.floor(h / r.width), 80), a.terminalRows = Math.max(_.floor(i / r.height), 24);
});
};
a.$watch("selectedTab.terminal", function(a) {
Expand Down