| | |
| | | |
| | | function rcmail_show_header_form(id) |
| | | { |
| | | var link, row, parent, ns, ps; |
| | | |
| | | link = document.getElementById(id + '-link'); |
| | | parent = link.parentNode; |
| | | var row, s, |
| | | link = document.getElementById(id + '-link'); |
| | | |
| | | if ((ns = rcmail_next_sibling(link))) |
| | | ns.style.display = 'none'; |
| | | else if ((ps = rcmail_prev_sibling(link))) |
| | | ps.style.display = 'none'; |
| | | 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'); |
| | | var headers_div = document.getElementById('compose-headers-div'); |
| | | 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) + 'px'; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function rcmail_hide_header_form(id) |
| | | { |
| | | var row, parent, ns, link, links; |
| | | var row, ns, |
| | | link = document.getElementById(id + '-link'), |
| | | parent = link.parentNode, |
| | | links = parent.getElementsByTagName('a'); |
| | | |
| | | link = document.getElementById(id + '-link'); |
| | | link.style.display = ''; |
| | | |
| | | parent = link.parentNode; |
| | | links = parent.getElementsByTagName('a'); |
| | | |
| | | 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 (links[j].style.display != 'none') |
| | | if ((ns = rcmail_next_sibling(links[i]))) { |
| | | ns.style.display = ''; |
| | | break; |
| | | } |
| | | ns.style.display = ''; |
| | | break; |
| | | } |
| | | |
| | | document.getElementById('_' + id).value = ''; |
| | | |
| | | if ((row = document.getElementById('compose-' + id))) |
| | | { |
| | | var div = document.getElementById('compose-div'); |
| | | var headers_div = document.getElementById('compose-headers-div'); |
| | | 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) + 'px'; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | |
| | | |
| | | function rcmail_init_compose_form() |
| | | { |
| | | var cc_field = document.getElementById('_cc'); |
| | | if (cc_field && cc_field.value!='') |
| | | 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'); |
| | | |
| | | var bcc_field = document.getElementById('_bcc'); |
| | | if (bcc_field && bcc_field.value!='') |
| | | 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); }; |
| | | form.onkeydown = function (e) { |
| | | if (rcube_event.get_keycode(e) == 27) |
| | | rcube_event.cancel(e); |
| | | }; |
| | | } |
| | | |
| | | // fix editor position on some browsers |
| | | div.style.top = parseInt(headers_div.offsetHeight, 10) + 'px'; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | function rcube_mail_ui() |
| | | { |
| | | this.markmenu = $('#markmessagemenu'); |
| | | this.searchmenu = $('#searchmenu'); |
| | | this.messagemenu = $('#messagemenu'); |
| | | this.listmenu = $('#listmenu'); |
| | | this.popupmenus = { |
| | | markmenu:'markmessagemenu', |
| | | searchmenu:'searchmenu', |
| | | messagemenu:'messagemenu', |
| | | listmenu:'listmenu', |
| | | dragmessagemenu:'dragmessagemenu', |
| | | groupmenu:'groupoptionsmenu' |
| | | }; |
| | | |
| | | var obj; |
| | | for (var k in this.popupmenus) { |
| | | obj = $('#'+this.popupmenus[k]) |
| | | if (obj.length) |
| | | this[k] = obj; |
| | | } |
| | | } |
| | | |
| | | rcube_mail_ui.prototype = { |
| | | |
| | | show_markmenu: function(show) |
| | | show_popupmenu: function(obj, refname, show, above) |
| | | { |
| | | if (typeof show == 'undefined') |
| | | show = this.markmenu.is(':visible') ? false : true; |
| | | show = obj.is(':visible') ? false : true; |
| | | |
| | | var ref = rcube_find_object(refname); |
| | | if (show && ref) { |
| | | var pos = $(ref).offset(); |
| | | obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.offsetHeight)) }); |
| | | } |
| | | |
| | | var ref = rcube_find_object('markreadbutton'); |
| | | if (show && ref) |
| | | this.markmenu.css({ left:ref.offsetLeft, top:(ref.offsetTop + ref.offsetHeight) }); |
| | | |
| | | this.markmenu[show?'show':'hide'](); |
| | | obj[show?'show':'hide'](); |
| | | }, |
| | | |
| | | show_markmenu: function(show) |
| | | { |
| | | this.show_popupmenu(this.markmenu, 'markreadbutton', show); |
| | | }, |
| | | |
| | | show_messagemenu: function(show) |
| | | { |
| | | if (typeof show == 'undefined') |
| | | show = this.messagemenu.is(':visible') ? false : true; |
| | | this.show_popupmenu(this.messagemenu, 'messagemenulink', show); |
| | | }, |
| | | |
| | | var ref = rcube_find_object('messagemenulink'); |
| | | if (show && ref) |
| | | this.messagemenu.css({ left:ref.offsetLeft, top:(ref.offsetTop + ref.offsetHeight) }); |
| | | |
| | | this.messagemenu[show?'show':'hide'](); |
| | | show_groupmenu: function(show) |
| | | { |
| | | this.show_popupmenu(this.groupmenu, 'groupactionslink', show, true); |
| | | }, |
| | | |
| | | show_searchmenu: function(show) |
| | |
| | | |
| | | var ref = rcube_find_object('listmenulink'); |
| | | if (show && ref) { |
| | | var pos = $(ref).offset(); |
| | | var pos = $(ref).offset(), |
| | | menuwidth = this.listmenu.width(), |
| | | pagewidth = $(document).width(); |
| | | |
| | | if (pagewidth - pos.left < menuwidth && pos.left > menuwidth) |
| | | pos.left = pos.left - menuwidth; |
| | | |
| | | this.listmenu.css({ left:pos.left, top:(pos.top + ref.offsetHeight + 2)}); |
| | | // set form values |
| | | $('input[name="sort_col"][value="'+rcmail.env.sort_col+'"]').attr('checked', 1); |
| | |
| | | { |
| | | this.show_listmenu(); |
| | | |
| | | var sort = $('input[name="sort_col"]:checked').val(); |
| | | var ord = $('input[name="sort_ord"]:checked').val(); |
| | | var thread = $('input[name="view"]:checked').val(); |
| | | var cols = $('input[name="list_col[]"]:checked') |
| | | .map(function(){ return this.value; }).get(); |
| | | var sort = $('input[name="sort_col"]:checked').val(), |
| | | ord = $('input[name="sort_ord"]:checked').val(), |
| | | thread = $('input[name="view"]:checked').val(), |
| | | cols = $('input[name="list_col[]"]:checked') |
| | | .map(function(){ return this.value; }).get(); |
| | | |
| | | rcmail.set_list_options(cols, sort, ord, thread == 'thread' ? 1 : 0); |
| | | }, |
| | |
| | | this.show_markmenu(false); |
| | | else if (this.messagemenu && this.messagemenu.is(':visible') && target != rcube_find_object('messagemenulink')) |
| | | this.show_messagemenu(false); |
| | | else if (this.dragmessagemenu && this.dragmessagemenu.is(':visible') && !rcube_mouse_is_over(evt, rcube_find_object('dragmessagemenu'))) |
| | | this.dragmessagemenu.hide(); |
| | | else if (this.groupmenu && this.groupmenu.is(':visible') && target != rcube_find_object('groupactionslink')) |
| | | this.show_groupmenu(false); |
| | | else if (this.listmenu && this.listmenu.is(':visible') && target != rcube_find_object('listmenulink')) { |
| | | var menu = rcube_find_object('listmenu'); |
| | | while (target.parentNode) { |
| | |
| | | body_keypress: function(evt, p) |
| | | { |
| | | if (rcube_event.get_keycode(evt) == 27) { |
| | | if (this.markmenu && this.markmenu.is(':visible')) |
| | | this.show_markmenu(false); |
| | | if (this.searchmenu && this.searchmenu.is(':visible')) |
| | | this.show_searchmenu(false); |
| | | if (this.messagemenu && this.messagemenu.is(':visible')) |
| | | this.show_messagemenu(false); |
| | | if (this.listmenu && this.listmenu.is(':visible')) |
| | | this.show_listmenu(false); |
| | | for (var k in this.popupmenus) { |
| | | if (this[k] && this[k].is(':visible')) |
| | | this[k].hide(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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' }); |
| | | rcmail.addEventListener('menu-open', 'open_listmenu', rcmail_ui); |
| | | rcmail.addEventListener('menu-save', 'save_listmenu', rcmail_ui); |
| | | if (rcmail.env.task == 'mail') { |
| | | rcmail.addEventListener('menu-open', 'open_listmenu', rcmail_ui); |
| | | rcmail.addEventListener('menu-save', 'save_listmenu', rcmail_ui); |
| | | rcmail.gui_object('message_dragmenu', 'dragmessagemenu'); |
| | | } |
| | | } |