From caf32d9598ca2298c57653b8d759f5c2807603dd Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 13 Jun 2012 09:27:58 +0100 Subject: [PATCH] Instituted minimum height for edit textareas --- core/modules/macros/edit/editors/texteditor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/modules/macros/edit/editors/texteditor.js b/core/modules/macros/edit/editors/texteditor.js index bdfd160a9..93401d85c 100644 --- a/core/modules/macros/edit/editors/texteditor.js +++ b/core/modules/macros/edit/editors/texteditor.js @@ -12,6 +12,8 @@ An editor plugin for editting text /*global $tw: false */ "use strict"; +var MIN_TEXT_AREA_HEIGHT = 100; + function TextEditor(macroNode) { this.macroNode = macroNode; } @@ -80,7 +82,7 @@ TextEditor.prototype.saveChanges = function() { }; TextEditor.prototype.fixHeight = function() { - if(this.macroNode.child && this.macroNode.child.domNode) { + if(this.macroNode.child && this.macroNode.child.children[0] && this.macroNode.child.children[0].type === "textarea") { var wrapper = this.macroNode.child.domNode, textarea = this.macroNode.child.children[0].domNode; // Set the text area height to 1px temporarily, which allows us to read the true scrollHeight @@ -88,7 +90,7 @@ TextEditor.prototype.fixHeight = function() { wrapper.style.height = textarea.style.height + "px"; textarea.style.overflow = "hidden"; textarea.style.height = "1px"; - textarea.style.height = textarea.scrollHeight + "px"; + textarea.style.height = Math.max(textarea.scrollHeight,MIN_TEXT_AREA_HEIGHT) + "px"; wrapper.style.height = prevWrapperHeight; } };