summaryrefslogtreecommitdiff
path: root/skins/default/functions.js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-10-02 08:39:49 +0000
committeralecpl <alec@alec.pl>2008-10-02 08:39:49 +0000
commit5f660cd7c4662c30921b76b04a7b9d92e82182df (patch)
tree39403ec7f26d27eb66c2efcae0cd65dd39debec7 /skins/default/functions.js
parenta2740628bb1dcfaa84d00ac05a80a92afdaffbd6 (diff)
- Minimize "inline" javascript use (#1485433)
Diffstat (limited to 'skins/default/functions.js')
-rw-r--r--skins/default/functions.js135
1 files changed, 135 insertions, 0 deletions
diff --git a/skins/default/functions.js b/skins/default/functions.js
new file mode 100644
index 000000000..1d8ac0290
--- /dev/null
+++ b/skins/default/functions.js
@@ -0,0 +1,135 @@
+/**
+ * RoundCube functions for default skin interface
+ */
+
+/**
+ * Settings
+ */
+
+function rcube_init_settings_tabs()
+{
+ if (window.rcmail && rcmail.env.action)
+ {
+ var action = rcmail.env.action=='preferences' ? 'default' : (rcmail.env.action.indexOf('identity')>0 ? 'identities' : rcmail.env.action);
+ var tab = document.getElementById('settingstab'+action);
+ }
+ else
+ var tab = document.getElementById('settingstabdefault');
+
+ if (tab)
+ tab.className = 'tablink-selected';
+}
+
+function rcube_show_advanced(visible)
+{
+ var rows = document.getElementsByTagName('TR');
+ for(var i=0; i<rows.length; i++)
+ if(rows[i].className && rows[i].className.match(/advanced/))
+ rows[i].style.display = visible ? (bw.ie ? 'block' : 'table-row') : 'none';
+}
+
+/**
+ * Mail Composing
+ */
+
+function rcmail_show_header_form(id, link)
+{
+ var row, parent, ns, ps, links;
+
+ if (link)
+ {
+ var parent = link.parentNode;
+
+ if ((ns = rcmail_next_sibling(link)))
+ parent.removeChild(ns);
+ else if ((ps = rcmail_prev_sibling(link)))
+ parent.removeChild(ps);
+
+ parent.removeChild(link);
+
+ if(!parent.getElementsByTagName('A').length)
+ document.getElementById('compose-links').style.display = 'none';
+ }
+
+ if (row = document.getElementById(id))
+ {
+ var div = document.getElementById('compose-div');
+ var headers_div = document.getElementById('compose-headers-div');
+ row.style.display = (document.all && !window.opera) ? 'block' : 'table-row';
+ div.style.top = (parseInt(headers_div.offsetHeight)) + 'px';
+ }
+
+ 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('rcmcomposecc');
+ if (cc_field && cc_field.value!='')
+ rcmail_show_header_form('compose-cc', document.getElementById('addcclink'));
+ var bcc_field = document.getElementById('rcmcomposebcc');
+ if (bcc_field && bcc_field.value!='')
+ rcmail_show_header_form('compose-bcc', document.getElementById('addbcclink'));
+}
+
+/**
+ * Mailbox view
+ */
+
+function rcube_mail_ui()
+{
+ this.markmenu = new rcube_layer('markmessagemenu');
+}
+
+rcube_mail_ui.prototype = {
+
+show_markmenu: function(show)
+{
+ if (typeof show == 'undefined')
+ show = this.markmenu.visible ? false : true;
+
+ var ref = rcube_find_object('markreadbutton');
+ if (show && ref)
+ this.markmenu.move(ref.offsetLeft, ref.offsetTop + ref.offsetHeight);
+
+ this.markmenu.show(show);
+},
+
+body_mouseup: function(evt, p)
+{
+ if (this.markmenu && this.markmenu.visible && evt.target != rcube_find_object('markreadbutton'))
+ this.show_markmenu(false);
+},
+
+body_keypress: function(evt, p)
+{
+ if (rcube_event.get_keycode(evt) == 27 && this.markmenu && this.markmenu.visible)
+ this.show_markmenu(false);
+}
+
+};
+
+var rcmail_ui;// = new rcube_mail_ui();
+
+function rcube_init_mail_ui()
+{
+ rcmail_ui = new rcube_mail_ui();
+ rcube_event.add_listener({ object:rcmail_ui, method:'body_mouseup', event:'mouseup' });
+ rcube_event.add_listener({ object:rcmail_ui, method:'body_keypress', event:'keypress' });
+}