From c88a1d43dcdfa6674ed44b9358743b6994f2303f Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Sat, 12 Dec 2009 22:37:38 -0600 Subject: [PATCH] Another Textarea Resizing Tweak Handle the 'Change page name' part of the form more intelligently. --- public/javascripts/page_helper.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/public/javascripts/page_helper.js b/public/javascripts/page_helper.js index 8c6843b1..c476e6a5 100644 --- a/public/javascripts/page_helper.js +++ b/public/javascripts/page_helper.js @@ -61,8 +61,12 @@ function updateSize(elt, w, h) { var parentwidth = $('Content').getWidth(); var f = $('MarkupHelp'); if (f.visible()) { parentwidth = parentwidth - f.getWidth() - 20 } + var changename = $('alter_title'); + if (changename) { + parentheight = parentheight - changename.parentNode.getHeight()-2*h; + } elt.writeAttribute({'cols': Math.floor(parentwidth/w) - 1, - 'rows': Math.floor(parentheight/h) - 6 }); + 'rows': Math.floor(parentheight/h) - 4 }); elt.setStyle({Width: parentwidth, Height: parentheight}); } @@ -76,6 +80,12 @@ function resizeableTextarea() { $$('textarea#content').each( function(textarea) { var w = textarea.getWidth()/textarea.getAttribute('cols'); var h = textarea.getStyle('lineHeight').replace(/(\d*)px/, "$1"); + var changename = $('alter_title'); + if (changename) { + Event.observe(changename.parentNode, 'change', function() { + updateSize(textarea, w, h); + }); + } Event.observe(hidebutton, 'click', function(){ if (f.visible()) { f.hide();