Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-25455] Avoid zero height of CodeMirror textarea
  • Loading branch information
vjuranek committed Jan 16, 2015
1 parent c8806c9 commit e9aeaf1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions core/src/main/resources/lib/form/textarea/textarea.js
@@ -1,5 +1,15 @@
Behaviour.specify("TEXTAREA.codemirror", 'textarea', 0, function(e) {
var h = e.clientHeight;
//ensure, that textarea is visible, when obtaining its height, see JENKINS-25455
function getTextareaHeight() {
var p = e.parentNode.parentNode; //first parent is CodeMirror div, second is actual element which needs to be visible
var display = p.style.display;
p.style.display = "";
var h = e.clientHeight;
p.style.display = display;
return h;
}

var h = e.clientHeight || getTextareaHeight();
var config = e.getAttribute("codemirror-config") || "";
config = eval('({'+config+'})');
var codemirror = CodeMirror.fromTextArea(e,config);
Expand All @@ -19,7 +29,13 @@ Behaviour.specify("TEXTAREA.codemirror", 'textarea', 0, function(e) {
Element.on(e.up('form'),"jenkins:apply", function() {
e.value = codemirror.getValue()
})
}
}

//refresh CM when there are some layout updates
function refreshCM() {
codemirror.refresh();
}
layoutUpdateCallback.add(refreshCM);
});

Behaviour.specify("DIV.textarea-preview-container", 'textarea', 100, function (e) {
Expand Down

0 comments on commit e9aeaf1

Please sign in to comment.