##// END OF EJS Templates
Apply width and height to outter most div of the tab widget.
Apply width and height to outter most div of the tab widget.

File last commit:

r20657:d4563772
r21464:39954bd8
Show More
main.js
63 lines | 2.1 KiB | application/javascript | JavascriptLexer
Thomas Kluyver
Basic infrastructure for terminal page
r18480 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
require([
'jquery',
'termjs',
Thomas Kluyver
Terminal basically working...
r18481 'base/js/utils',
'base/js/page',
Thomas Kluyver
Load common_config, and load extensions specified therein
r19633 'services/config',
Thomas Kluyver
Terminal basically working...
r18481 'terminal/js/terminado',
Thomas Kluyver
Basic infrastructure for terminal page
r18480 'custom/custom',
], function(
$,
Thomas Kluyver
Terminal basically working...
r18481 termjs,
utils,
page,
Thomas Kluyver
Load common_config, and load extensions specified therein
r19633 configmod,
Thomas Kluyver
Terminal basically working...
r18481 terminado
){
Matthias Bussonnier
Some code cleanup in javascript and python...
r19739 "use strict";
Thomas Kluyver
Terminal basically working...
r18481 page = new page.Page();
Thomas Kluyver
Load common_config, and load extensions specified therein
r19633
Thomas Kluyver
Fix instantiating config in editor and terminal
r19635 var common_config = new configmod.ConfigSection('common',
{base_url: utils.get_body_data('baseUrl')});
Thomas Kluyver
Load common_config, and load extensions specified therein
r19633 common_config.load();
Thomas Kluyver
Terminal basically working...
r18481 // Test size: 25x80
Bussonnier Matthias
recompute dummy size dynamically + styling in css
r18489 var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;};
Thomas Kluyver
Add comment explaining 1.02 factor
r18492 // 1.02 here arrived at by trial and error to make the spacing look right
Bussonnier Matthias
recompute dummy size dynamically + styling in css
r18489 var termColWidth = function() { return 1.02 * $("#dummy-screen-rows")[0].offsetWidth / 80;};
Thomas Kluyver
Terminal basically working...
r18481
var base_url = utils.get_body_data('baseUrl');
Thomas Kluyver
Multiple terminals and conditional initialisation
r18482 var ws_path = utils.get_body_data('wsPath');
Thomas Kluyver
Terminal basically working...
r18481 var ws_url = location.protocol.replace('http', 'ws') + "//" + location.host
Thomas Kluyver
Multiple terminals and conditional initialisation
r18482 + base_url + ws_path;
Thomas Kluyver
Terminal basically working...
r18481
var header = $("#header")[0]
function calculate_size() {
Min RK
use $(window).height() instead of window.innerHeight...
r20657 var height = $(window).height() - header.offsetHeight;
Matthias Bussonnier
Some code cleanup in javascript and python...
r19739 var width = $('#terminado-container').width();
Bussonnier Matthias
recompute dummy size dynamically + styling in css
r18489 var rows = Math.min(1000, Math.max(20, Math.floor(height/termRowHeight())-1));
var cols = Math.min(1000, Math.max(40, Math.floor(width/termColWidth())-1));
console.log("resize to :", rows , 'rows by ', cols, 'columns');
Thomas Kluyver
Terminal basically working...
r18481 return {rows: rows, cols: cols};
}
page.show_header();
Matthias Bussonnier
Some code cleanup in javascript and python...
r19739 var size = calculate_size();
Thomas Kluyver
Terminal basically working...
r18481 var terminal = terminado.make_terminal($("#terminado-container")[0], size, ws_url);
page.show_site();
Thomas Kluyver
Load common_config, and load extensions specified therein
r19633 utils.load_extensions_from_config(common_config);
Thomas Kluyver
Terminal basically working...
r18481 window.onresize = function() {
var geom = calculate_size();
terminal.term.resize(geom.cols, geom.rows);
terminal.socket.send(JSON.stringify(["set_size", geom.rows, geom.cols,
Min RK
use $(window).height() instead of window.innerHeight...
r20657 $(window).height(), $(window).width()]));
Thomas Kluyver
Terminal basically working...
r18481 };
Thomas Kluyver
Basic infrastructure for terminal page
r18480
});