From bdd40e2734b26c794ff1fd6082be6fae1346357b Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Wed, 21 Jan 2015 13:19:52 -0800 Subject: [PATCH 1/3] Explicitly size codemirror editor in Edit app --- IPython/html/static/edit/js/main.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/IPython/html/static/edit/js/main.js b/IPython/html/static/edit/js/main.js index 898dd199a..2dfc0c4bd 100644 --- a/IPython/html/static/edit/js/main.js +++ b/IPython/html/static/edit/js/main.js @@ -2,6 +2,7 @@ // Distributed under the terms of the Modified BSD License. require([ + 'jquery', 'base/js/namespace', 'base/js/utils', 'base/js/page', @@ -14,6 +15,7 @@ require([ 'edit/js/notificationarea', 'custom/custom', ], function( + $, IPython, utils, page, @@ -75,4 +77,14 @@ require([ } }; + // Make sure the codemirror editor is sized appropriatley. + var _handle_resize = function() { + var header = $('#header'); + var padding = header.outerHeight(true) - header.innerHeight(); + $('div.CodeMirror').height(window.innerHeight - header.height() - 2*padding); + }; + window.onresize = _handle_resize; + + // On document ready, resize codemirror. + $(_handle_resize); }); From 6b9558c613000450bec862cb65e3c57ac05f67b4 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Thu, 22 Jan 2015 09:51:49 -0800 Subject: [PATCH 2/3] Be a little more clear about sizing logic. --- IPython/html/static/edit/js/main.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/edit/js/main.js b/IPython/html/static/edit/js/main.js index 2dfc0c4bd..cb5f1946c 100644 --- a/IPython/html/static/edit/js/main.js +++ b/IPython/html/static/edit/js/main.js @@ -80,8 +80,15 @@ require([ // Make sure the codemirror editor is sized appropriatley. var _handle_resize = function() { var header = $('#header'); - var padding = header.outerHeight(true) - header.innerHeight(); - $('div.CodeMirror').height(window.innerHeight - header.height() - 2*padding); + + // The header doesn't have a margin or padding above it. Calculate + // the lower margin&padding by subtracting the innerHeight from the + // outerHeight. + var header_margin_bottom = header.outerHeight(true) - header.innerHeight(); + + // When scaling CodeMirror, subtract the header lower margin from the + // height twice. Once for top padding and once for bottom padding. + $('div.CodeMirror').height(window.innerHeight - header.height() - 2*header_margin_bottom); }; window.onresize = _handle_resize; From efe654e59d48894ad0a5d236b41861ea404a638b Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Thu, 22 Jan 2015 13:23:27 -0800 Subject: [PATCH 3/3] Use longer version of document.ready --- IPython/html/static/edit/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/html/static/edit/js/main.js b/IPython/html/static/edit/js/main.js index cb5f1946c..61822e3cd 100644 --- a/IPython/html/static/edit/js/main.js +++ b/IPython/html/static/edit/js/main.js @@ -93,5 +93,5 @@ require([ window.onresize = _handle_resize; // On document ready, resize codemirror. - $(_handle_resize); + $(document).ready(_handle_resize); });