From 7863921d53cd301afb394d2c7b9b0e5cbe063db8 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 08 Nov 2013 08:06:31 -0500
Subject: [PATCH] Adjust recipients textarea size according to conent. This reduces the height to 1 row on Firefox < 25 which renders textareas rows+1 heigh (#1489198)

---
 skins/larry/ui.js |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/skins/larry/ui.js b/skins/larry/ui.js
index 0fd0241..660b18f 100644
--- a/skins/larry/ui.js
+++ b/skins/larry/ui.js
@@ -113,7 +113,6 @@
         rcmail.addEventListener('aftertoggle-editor', function(){ window.setTimeout(function(){ layout_composeview() }, 200); });
         rcmail.addEventListener('aftersend-attachment', show_uploadform);
         rcmail.addEventListener('add-recipient', function(p){ show_header_row(p.field, true); });
-        layout_composeview();
 
         // Show input elements with non-empty value
         var f, v, field, fields = ['cc', 'bcc', 'replyto', 'followupto'];
@@ -132,6 +131,10 @@
           layout_composeview();
           return false;
         }).css('cursor', 'pointer');
+
+        // adjust hight when textarea starts to scroll
+        $("textarea[name='_to'], textarea[name='_cc'], textarea[name='_bcc']").change(function(e){ adjust_compose_editfields(this); }).change();
+        rcmail.addEventListener('autocomplete_insert', function(p){ adjust_compose_editfields(p.field); });
 
         // toggle compose options if opened in new window and they were visible before
         var opener_rc = rcmail.opener();
@@ -428,6 +431,16 @@
     // STUB
   }
 
+  function adjust_compose_editfields(elem)
+  {
+    if (elem.nodeName == 'TEXTAREA') {
+      var $elem = $(elem), line_height = 14,  // hard-coded because some browsers only provide the outer height in elem.clientHeight
+        content_height = elem.scrollHeight,
+        rows = elem.value.length > 80 && content_height > line_height*1.5 ? 2 : 1;
+      $elem.css('height', (line_height*rows) + 'px');
+      layout_composeview();
+    }
+  }
 
   function layout_composeview()
   {

--
Gitblit v1.9.1