From 7863921d53cd301afb394d2c7b9b0e5cbe063db8 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Fri, 8 Nov 2013 14:06:09 +0100 Subject: 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 file changed, 14 insertions(+), 1 deletion(-) diff --git a/skins/larry/ui.js b/skins/larry/ui.js index 0fd0241f7..660b18ff9 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -113,7 +113,6 @@ function rcube_mail_ui() 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']; @@ -133,6 +132,10 @@ function rcube_mail_ui() 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(); if (opener_rc && opener_rc.env.action == 'compose' && $('#composeoptionstoggle', opener.document).hasClass('remove')) @@ -428,6 +431,16 @@ function rcube_mail_ui() // 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() { -- cgit v1.2.3