summaryrefslogtreecommitdiff
path: root/skins
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-06-30 08:40:39 +0000
committeralecpl <alec@alec.pl>2010-06-30 08:40:39 +0000
commit3940ba65be1993c4a2c2be4599f53d3018228783 (patch)
tree9d426e0921c6973691474b219e33377982dbd70b /skins
parentedfe91737e573e9f4209451e3d59a6839b1687f0 (diff)
- Resize editor after switching to html mode
- create toggle-editor command in app.js, to make possible binding to this command - Code cleanup in rcmail_ui (moved compose-related functions into rcmail_ui)
Diffstat (limited to 'skins')
-rw-r--r--skins/default/functions.js258
-rw-r--r--skins/default/templates/compose.html14
2 files changed, 137 insertions, 135 deletions
diff --git a/skins/default/functions.js b/skins/default/functions.js
index 3a97448ac..258742e69 100644
--- a/skins/default/functions.js
+++ b/skins/default/functions.js
@@ -22,129 +22,7 @@ function rcube_show_advanced(visible)
}
/**
- * Mail Composing
- */
-
-function rcmail_show_header_form(id)
-{
- var row, s,
- link = document.getElementById(id + '-link');
-
- if ((s = rcmail_next_sibling(link)))
- s.style.display = 'none';
- else if ((s = rcmail_prev_sibling(link)))
- s.style.display = 'none';
-
- link.style.display = 'none';
-
- if ((row = document.getElementById('compose-' + id))) {
- var div = document.getElementById('compose-div'),
- headers_div = document.getElementById('compose-headers-div');
- row.style.display = (document.all && !window.opera) ? 'block' : 'table-row';
- div.style.top = (parseInt(headers_div.offsetHeight, 10) + 1) + 'px';
- rcmail_resize_compose_body();
- }
-
- return false;
-}
-
-function rcmail_hide_header_form(id)
-{
- var row, ns,
- link = document.getElementById(id + '-link'),
- parent = link.parentNode,
- links = parent.getElementsByTagName('a');
-
- link.style.display = '';
-
- for (var i=0; i<links.length; i++)
- if (links[i].style.display != 'none')
- for (var j=i+1; j<links.length; j++)
- if (links[j].style.display != 'none')
- if ((ns = rcmail_next_sibling(links[i]))) {
- ns.style.display = '';
- break;
- }
-
- document.getElementById('_' + id).value = '';
-
- if ((row = document.getElementById('compose-' + id))) {
- var div = document.getElementById('compose-div'),
- headers_div = document.getElementById('compose-headers-div');
- row.style.display = 'none';
- div.style.top = (parseInt(headers_div.offsetHeight, 10) + 1) + 'px';
- rcmail_resize_compose_body();
- }
-
- return false;
-}
-
-function rcmail_next_sibling(elm)
-{
- var ns = elm.nextSibling;
- while (ns && ns.nodeType == 3)
- ns = ns.nextSibling;
- return ns;
-}
-
-function rcmail_prev_sibling(elm)
-{
- var ps = elm.previousSibling;
- while (ps && ps.nodeType == 3)
- ps = ps.previousSibling;
- return ps;
-}
-
-function rcmail_init_compose_form()
-{
- var cc_field = document.getElementById('_cc'),
- bcc_field = document.getElementById('_bcc'),
- div = document.getElementById('compose-div'),
- headers_div = document.getElementById('compose-headers-div');
-
- if (cc_field && cc_field.value != '')
- rcmail_show_header_form('cc');
-
- if (bcc_field && bcc_field.value != '')
- rcmail_show_header_form('bcc');
-
- // prevent from form data loss when pressing ESC key in IE
- if (bw.ie) {
- var form = rcube_find_object('form');
- form.onkeydown = function (e) {
- if (rcube_event.get_keycode(e) == 27)
- rcube_event.cancel(e);
- };
- }
-
- $(window).resize(function() {
- rcmail_resize_compose_body();
- });
-
- $('#compose-container').resize(function() {
- rcmail_resize_compose_body();
- });
-
- div.style.top = (parseInt(headers_div.offsetHeight, 10) + 1) + 'px';
- $(window).resize();
-}
-
-function rcmail_resize_compose_body(elem)
-{
- var ed, div = $('#compose-div'), w = div.width(), h = div.height();
- w = w-4;
- h = h-25;
-
- $('#compose-body').width(w-(bw.ie || bw.opera || bw.safari ? 2 : 0)+'px').height(h+'px');
-
- if (window.tinyMCE && tinyMCE.get('compose-body')) {
- $('#compose-body_tbl').width((w+4)+'px').height('');
- $('#compose-body_ifr').width((w+2)+'px').height((h-54)+'px');
- }
-}
-
-/**
- * Mailbox view
+ * Mail UI
*/
function rcube_mail_ui()
@@ -160,7 +38,7 @@ function rcube_mail_ui()
composemenu:'composeoptionsmenu',
uploadform:'attachment-form'
};
-
+
var obj;
for (var k in this.popupmenus) {
obj = $('#'+this.popupmenus[k])
@@ -181,7 +59,7 @@ show_popupmenu: function(obj, refname, show, above)
var pos = $(ref).offset();
obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.offsetHeight)) });
}
-
+
obj[show?'show':'hide']();
},
@@ -238,15 +116,15 @@ show_searchmenu: function(show)
}
this.searchmenu[show?'show':'hide']();
},
-
+
set_searchmod: function(elem)
{
if (!rcmail.env.search_mods)
rcmail.env.search_mods = {};
-
+
if (!rcmail.env.search_mods[rcmail.env.mailbox])
rcmail.env.search_mods[rcmail.env.mailbox] = rcube_clone_object(rcmail.env.search_mods['*']);
-
+
if (!elem.checked)
delete(rcmail.env.search_mods[rcmail.env.mailbox][elem.value]);
else
@@ -417,10 +295,130 @@ switch_preview_pane: function(elem)
rcmail.show_contentframe(false);
rcmail.http_post('save-pref', '_name=preview_pane&_value=0');
}
+},
+
+/* Message composing */
+init_compose_form: function()
+{
+ var cc_field = document.getElementById('_cc'),
+ bcc_field = document.getElementById('_bcc'),
+ div = document.getElementById('compose-div'),
+ headers_div = document.getElementById('compose-headers-div');
+
+ if (cc_field && cc_field.value != '')
+ rcmail_show_header_form('cc');
+
+ if (bcc_field && bcc_field.value != '')
+ rcmail_show_header_form('bcc');
+
+ // prevent from form data loss when pressing ESC key in IE
+ if (bw.ie) {
+ var form = rcube_find_object('form');
+ form.onkeydown = function (e) {
+ if (rcube_event.get_keycode(e) == 27)
+ rcube_event.cancel(e);
+ };
+ }
+
+ $(window).resize(function() {
+ rcmail_ui.resize_compose_body();
+ });
+
+ $('#compose-container').resize(function() {
+ rcmail_ui.resize_compose_body();
+ });
+
+ div.style.top = (parseInt(headers_div.offsetHeight, 10) + 1) + 'px';
+ $(window).resize();
+},
+
+resize_compose_body: function()
+{
+ var ed, div = $('#compose-div'), w = div.width(), h = div.height();
+ w = w-4;
+ h = h-25;
+
+ $('#compose-body').width(w-(bw.ie || bw.opera || bw.safari ? 2 : 0)+'px').height(h+'px');
+
+ if (window.tinyMCE && tinyMCE.get('compose-body')) {
+ $('#compose-body_tbl').width((w+4)+'px').height('');
+ $('#compose-body_ifr').width((w+2)+'px').height((h-54)+'px');
+ }
+},
+
+show_header_form: function(id)
+{
+ var row, s,
+ link = document.getElementById(id + '-link');
+
+ if ((s = this.next_sibling(link)))
+ s.style.display = 'none';
+ else if ((s = this.prev_sibling(link)))
+ s.style.display = 'none';
+
+ link.style.display = 'none';
+
+ if ((row = document.getElementById('compose-' + id))) {
+ var div = document.getElementById('compose-div'),
+ headers_div = document.getElementById('compose-headers-div');
+ row.style.display = (document.all && !window.opera) ? 'block' : 'table-row';
+ div.style.top = (parseInt(headers_div.offsetHeight, 10) + 1) + 'px';
+ this.resize_compose_body();
+ }
+
+ return false;
+},
+
+hide_header_form: function(id)
+{
+ var row, ns,
+ link = document.getElementById(id + '-link'),
+ parent = link.parentNode,
+ links = parent.getElementsByTagName('a');
+
+ link.style.display = '';
+
+ for (var i=0; i<links.length; i++)
+ if (links[i].style.display != 'none')
+ for (var j=i+1; j<links.length; j++)
+ if (links[j].style.display != 'none')
+ if ((ns = this.next_sibling(links[i]))) {
+ ns.style.display = '';
+ break;
+ }
+
+ document.getElementById('_' + id).value = '';
+
+ if ((row = document.getElementById('compose-' + id))) {
+ var div = document.getElementById('compose-div'),
+ headers_div = document.getElementById('compose-headers-div');
+ row.style.display = 'none';
+ div.style.top = (parseInt(headers_div.offsetHeight, 10) + 1) + 'px';
+ this.resize_compose_body();
+ }
+
+ return false;
+},
+
+next_sibling: function(elm)
+{
+ var ns = elm.nextSibling;
+ while (ns && ns.nodeType == 3)
+ ns = ns.nextSibling;
+ return ns;
+},
+
+prev_sibling: function(elm)
+{
+ var ps = elm.previousSibling;
+ while (ps && ps.nodeType == 3)
+ ps = ps.previousSibling;
+ return ps;
}
};
+
var rcmail_ui;
function rcube_init_mail_ui()
@@ -436,7 +434,11 @@ function rcube_init_mail_ui()
rcmail.addEventListener('menu-open', 'open_listmenu', rcmail_ui);
rcmail.addEventListener('menu-save', 'save_listmenu', rcmail_ui);
rcmail.addEventListener('aftersend-attachment', 'show_uploadform', rcmail_ui);
+ rcmail.addEventListener('aftertoggle-editor', 'resize_compose_body', rcmail_ui);
rcmail.gui_object('message_dragmenu', 'dragmessagemenu');
+
+ if (rcmail.env.action == 'compose')
+ rcmail_ui.init_compose_form();
}
}
diff --git a/skins/default/templates/compose.html b/skins/default/templates/compose.html
index 96f771f8f..bd5860372 100644
--- a/skins/default/templates/compose.html
+++ b/skins/default/templates/compose.html
@@ -13,7 +13,7 @@
}
</style>
</head>
-<body onload="rcmail_init_compose_form(); rcube_init_mail_ui()">
+<body onload="rcube_init_mail_ui()">
<roundcube:include file="/includes/taskbar.html" />
<roundcube:include file="/includes/header.html" />
@@ -55,11 +55,11 @@
<roundcube:object name="composeHeaders" part="from" form="form" id="_from" tabindex="1" />
</td>
<td id="formlinks">
- <a href="#cc" onclick="return rcmail_show_header_form('cc')" id="cc-link"><roundcube:label name="addcc" /></a>
+ <a href="#cc" onclick="return rcmail_ui.show_header_form('cc')" id="cc-link"><roundcube:label name="addcc" /></a>
<span class="separator">|</span>
- <a href="#bcc" onclick="return rcmail_show_header_form('bcc')" id="bcc-link"><roundcube:label name="addbcc" /></a>
+ <a href="#bcc" onclick="return rcmail_ui.show_header_form('bcc')" id="bcc-link"><roundcube:label name="addbcc" /></a>
<span class="separator">|</span>
- <a href="#reply-to" onclick="return rcmail_show_header_form('replyto')" id="replyto-link"><roundcube:label name="addreplyto" /></a>
+ <a href="#reply-to" onclick="return rcmail_ui.show_header_form('replyto')" id="replyto-link"><roundcube:label name="addreplyto" /></a>
</td>
</tr><tr>
<td class="title top"><label for="_to"><roundcube:label name="to" /></label></td>
@@ -68,7 +68,7 @@
</td>
</tr><tr id="compose-cc">
<td class="title top">
- <a href="#cc" onclick="return rcmail_hide_header_form('cc');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
+ <a href="#cc" onclick="return rcmail_ui.hide_header_form('cc');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
<label for="_cc"><roundcube:label name="cc" /></label>
</td>
<td colspan="2" class="editfield">
@@ -76,7 +76,7 @@
</td>
</tr><tr id="compose-bcc">
<td class="title top">
- <a href="#bcc" onclick="return rcmail_hide_header_form('bcc');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
+ <a href="#bcc" onclick="return rcmail_ui.hide_header_form('bcc');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
<label for="_bcc"><roundcube:label name="bcc" /></label>
</td>
<td colspan="2" class="editfield">
@@ -84,7 +84,7 @@
</td>
</tr><tr id="compose-replyto">
<td class="title top">
- <a href="#replyto" onclick="return rcmail_hide_header_form('replyto');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
+ <a href="#replyto" onclick="return rcmail_ui.hide_header_form('replyto');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
<label for="_replyto"><roundcube:label name="replyto" /></label>
</td>
<td colspan="2" class="editfield">