1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-02 10:13:16 +00:00

Instituted minimum height for edit textareas

This commit is contained in:
Jeremy Ruston 2012-06-13 09:27:58 +01:00
parent e5b6d9a722
commit caf32d9598

View File

@ -12,6 +12,8 @@ An editor plugin for editting text
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
var MIN_TEXT_AREA_HEIGHT = 100;
function TextEditor(macroNode) { function TextEditor(macroNode) {
this.macroNode = macroNode; this.macroNode = macroNode;
} }
@ -80,7 +82,7 @@ TextEditor.prototype.saveChanges = function() {
}; };
TextEditor.prototype.fixHeight = 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, var wrapper = this.macroNode.child.domNode,
textarea = this.macroNode.child.children[0].domNode; textarea = this.macroNode.child.children[0].domNode;
// Set the text area height to 1px temporarily, which allows us to read the true scrollHeight // 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"; wrapper.style.height = textarea.style.height + "px";
textarea.style.overflow = "hidden"; textarea.style.overflow = "hidden";
textarea.style.height = "1px"; 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; wrapper.style.height = prevWrapperHeight;
} }
}; };