Add resizeHandler method for mail compose window, in order to control textArea size

This commit is contained in:
Hadi Nategh 2014-06-03 16:37:50 +00:00
parent a92a8c2f3b
commit 23ca90c448
4 changed files with 41 additions and 14 deletions

View File

@ -142,7 +142,6 @@ app.classes.mail = AppJS.extend(
window.resizeTo((w_h[0]?w_h[0]:870),(w_h[1]?w_h[1]:(screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight())));
break;
case 'mail.compose':
var app_registry = egw.link_get_registry('mail');
var that = this;
this.mail_isMainWindow = false;
this.compose_fieldExpander_hide();
@ -154,14 +153,9 @@ app.classes.mail = AppJS.extend(
that.compose_fieldExpander();
}
});
if (typeof app_registry['edit'] != 'undefined' && typeof app_registry['edit_popup'] != 'undefined' )
{
var w_h =app_registry['edit_popup'].split('x');
if (w_h[1] == 'egw_getWindowOuterHeight()') w_h[1] = (screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight());
}
/*Trigger compose_resizeHandler after the CKEditor is fully loaded*/
jQuery('#mail-compose').load ('load', function() {that.compose_resizeHandler();});
window.resizeTo((w_h[0]?w_h[0]:870),(w_h[1]?w_h[1]:(screen.availHeight<800?screen.availHeight:800)));
this.compose_fieldExpander();
break;
}
@ -3115,6 +3109,42 @@ app.classes.mail = AppJS.extend(
jQuery(".mailComposeJQueryCc,.mailComposeJQueryBcc,.mailComposeJQueryFolder").hide();
},
/**
* Control textArea size based on available free space at the bottom
*
*/
compose_resizeHandler: function()
{
var bodyH = jQuery('body').height();
var textArea = this.et2.getWidgetById('mail_plaintext');
var toolbar = jQuery('.mailSignature');
if (typeof textArea != 'undefined')
{
var textAreaH = textArea.node.clientHeight;
if (textArea.getParent().disabled)
{
textArea = this.et2.getWidgetById('mail_htmltext');
textAreaH = parseInt(textArea.getParent().node.clientHeight);
}
var freeSpace = (bodyH - Math.round(toolbar.height() + toolbar.offset().top) - 65);
if (textArea.id != "mail_htmltext")
{
textArea.set_height(textAreaH + freeSpace);
}
else if (typeof textArea != 'undefined' && textArea.id == 'mail_htmltext' && typeof textArea.getParent().node.children[1] != 'undefined')
{
jQuery(textArea.getParent().node.children[1].children[1].children[1]).css('height',textAreaH + (freeSpace - 90));
}
else
{
textArea.set_height(textAreaH + (freeSpace - 90));
}
}
},
/**
* Display Folder,Cc or Bcc fields in compose popup
*
@ -3192,6 +3222,7 @@ app.classes.mail = AppJS.extend(
}
}
}
this.compose_resizeHandler();
},
/**

View File

@ -102,10 +102,10 @@
</vbox>
<vbox class="mailComposeBodySection" width="99%">
<hbox disabled="@is_plain" class="mailComposeBody">
<htmlarea span="all" name="mail_htmltext" id="mail_htmltext" expand_toolbar="true" height="320px" width="100%" />
<htmlarea span="all" name="mail_htmltext" id="mail_htmltext" expand_toolbar="true" height="478px" width="100%" />
</hbox>
<hbox disabled="@is_html" class="mailComposeBody">
<textbox multiline="true" rows="15" cols="120" width="100%" span="all" no_lang="1" name="mail_plaintext" id="mail_plaintext"/>
<textbox multiline="true" rows="40" cols="120" width="100%" span="all" no_lang="1" name="mail_plaintext" id="mail_plaintext"/>
</hbox>
<groupbox class="mailSignature">
<menulist>

View File

@ -1211,9 +1211,6 @@ div#mail-index div#mail-index_mailPreview div#mail-index_mailPreviewHeadersSubje
#mail-compose .mail-compose_toolbar #mail-compose_priority span.et2_label {
margin-right: 3px;
}
#mail-compose table.et2_grid {
float: left;
}
#mail-compose .mailComposeHeaders,
#mail-compose .mailComposeHeadersSection {
margin: 2px 0;

View File

@ -548,7 +548,6 @@ div#mail-index{
/*// ###############################################################################*/
/*// Mail Header*/
table.et2_grid {float: left;}
.mailComposeHeaders,.mailComposeHeadersSection{
margin: 2px 0;