提交 e9aeaf11 编写于 作者: V Vojtech Juranek

[JENKINS-25455] Avoid zero height of CodeMirror textarea

上级 c8806c99
Behaviour.specify("TEXTAREA.codemirror", 'textarea', 0, function(e) {
//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);
......@@ -20,6 +30,12 @@ Behaviour.specify("TEXTAREA.codemirror", 'textarea', 0, function(e) {
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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册