From b0ff642d030dad2d94f2d1594dcf9fa9f9b06eec Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Wed, 4 Jul 2007 20:37:58 +0000 Subject: [PATCH] Added experimental code for resizing edit box SVN revision: 1877 --- src/elogd.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index 88e79ae7..f8087cb2 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -9385,6 +9385,27 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf(" document.form1.submit();\n"); rsprintf("}\n\n"); + if (!getcfg(lbs->name, "Message height", str, sizeof(str)) && + !getcfg(lbs->name, "Message width", str, sizeof(str))) { + /* javascript for resizing edit box */ + rsprintf("\nfunction init_resize()\n"); + rsprintf("{\n"); + rsprintf(" window.onresize = resize_textarea;\n"); + rsprintf(" resize_textarea();\n"); + rsprintf("}\n\n"); + rsprintf("function resize_textarea()\n"); + rsprintf("{\n"); + rsprintf(" p = document.form1.Text;\n"); + rsprintf(" t = p.offsetTop;\n"); + rsprintf(" while (p = p.offsetParent)\n"); + rsprintf(" t += p.offsetTop;\n"); + rsprintf(" height = window.innerHeight - t - 135;\n"); + rsprintf(" if (height < 300)\n"); + rsprintf(" height = 300;\n"); + rsprintf(" document.form1.Text.style.height = height;\n"); + rsprintf("}\n\n"); + } + /* strings for elcode.js */ rsprintf("linkText_prompt = \"%s\";\n", loc("Enter name of hyperlink")); rsprintf("linkURL_prompt = \"%s\";\n", loc("Enter URL of hyperlink")); @@ -9415,8 +9436,14 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if ((isparam("inlineatt") && *getparam("inlineatt")) || bpreview) strcpy(script, " OnLoad=\"document.form1.Text.focus();\""); - if (enc_selected == 0) - strcat(script, " OnLoad=\"elKeyInit();\" OnFocus=\"elKeyInit();\""); + if (enc_selected == 0) { + if (!getcfg(lbs->name, "Message height", str, sizeof(str)) && + !getcfg(lbs->name, "Message width", str, sizeof(str))) + strcat(script, " OnLoad=\"elKeyInit(); init_resize();\" OnFocus=\"elKeyInit();\""); + else + strcat(script, " OnLoad=\"elKeyInit();\" OnFocus=\"elKeyInit();\""); + } else + strcat(script, " OnLoad=\"init_resize();\""); if (getcfg(lbs->name, "Use Lock", str, sizeof(str)) && atoi(str) == 1) rsprintf("\n", script); @@ -10217,9 +10244,9 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL } /* main box for text box and icons */ - rsprintf("\n"); + rsprintf("\n"); //## if (enc_selected == 0) - rsprintf("\n"); + rsprintf("
\n"); if (enc_selected == 0 && show_smileys) { @@ -10254,7 +10281,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL } if (enc_selected == 0) - rsprintf("
\n"); + rsprintf("\n"); /* set textarea width */ width = 112; @@ -10351,7 +10378,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("