From d2dab21292a68eb8d72583ce6785d24d527b918d Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Fri, 9 Sep 2016 14:04:51 +0200 Subject: [PATCH] some changes to resizing --- app/assets/javascripts/editor/editor.js.erb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index eafe6f44..ceb24a6a 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -15,7 +15,6 @@ var CodeOceanEditor = { AUTOSAVE_INTERVAL: 15 * 1000, REQUEST_FOR_COMMENTS_DELAY: 3 * 60 * 1000, REQUEST_TOOLTIP_TIME: 5000, - EDITOR_HEIGHT_SUBST: 100, NONE: 0, WEBSOCKET: 1, @@ -200,15 +199,21 @@ var CodeOceanEditor = { this.createSubmission($('#autosave'), null); }, + resizeParentOfAceEditor: function (element){ + // calculate needed size: window height - position of top of button-bar - 60 for bar itself and margins + var windowHeight = window.innerHeight - $('#editor-buttons').offset().top - 60; + $(element).parent().height(windowHeight); + }, + initializeEditors: function () { $('.editor').each(function (index, element) { - // Resize frame. - var windowHeight = window.innerHeight - this.EDITOR_HEIGHT_SUBST; - $(element).parent().height(windowHeight); + // Resize frame on load + this.resizeParentOfAceEditor(element); + + // Resize frame on window size change $(window).resize(function(){ - var windowHeight = window.innerHeight - this.EDITOR_HEIGHT_SUBST; - $(element).parent().height(windowHeight); + this.resizeParentOfAceEditor(element); }.bind(this)); var editor = ace.edit(element);