Another Textarea Resizing Tweak

Handle the 'Change page name'
part of the form more intelligently.
This commit is contained in:
Jacques Distler 2009-12-12 22:37:38 -06:00
parent a58bee7437
commit c88a1d43dc

View file

@ -61,8 +61,12 @@ function updateSize(elt, w, h) {
var parentwidth = $('Content').getWidth(); var parentwidth = $('Content').getWidth();
var f = $('MarkupHelp'); var f = $('MarkupHelp');
if (f.visible()) { parentwidth = parentwidth - f.getWidth() - 20 } 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, 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}); elt.setStyle({Width: parentwidth, Height: parentheight});
} }
@ -76,6 +80,12 @@ function resizeableTextarea() {
$$('textarea#content').each( function(textarea) { $$('textarea#content').each( function(textarea) {
var w = textarea.getWidth()/textarea.getAttribute('cols'); var w = textarea.getWidth()/textarea.getAttribute('cols');
var h = textarea.getStyle('lineHeight').replace(/(\d*)px/, "$1"); 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(){ Event.observe(hidebutton, 'click', function(){
if (f.visible()) { if (f.visible()) {
f.hide(); f.hide();