| | |
| | | comm_path: './', |
| | | blankpage: 'program/resources/blank.gif', |
| | | recipients_separator: ',', |
| | | recipients_delimiter: ', ' |
| | | recipients_delimiter: ', ', |
| | | popup_width: 1150, |
| | | popup_width_small: 900 |
| | | }; |
| | | |
| | | // create protected reference to myself |
| | |
| | | |
| | | case 'extwin': |
| | | if (this.env.action == 'compose') { |
| | | var form = this.gui_objects.messageform; |
| | | var form = this.gui_objects.messageform, |
| | | win = this.open_window(''); |
| | | |
| | | $("input[name='_action']", form).val('compose'); |
| | | form.action = this.url('mail/compose', { _id: this.env.compose_id, _extwin: 1 }); |
| | | form.target = this.open_window('', 1100, 900); |
| | | form.target = win.name; |
| | | form.submit(); |
| | | } |
| | | else { |
| | | this.open_window(this.env.permaurl, 900, 900); |
| | | this.open_window(this.env.permaurl, true); |
| | | } |
| | | break; |
| | | |
| | |
| | | |
| | | // open attachment in frame if it's of a supported mimetype |
| | | if (command != 'download-attachment' && mimetype && this.env.mimetypes && $.inArray(mimetype, this.env.mimetypes) >= 0) { |
| | | var attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', this.html_identifier('rcubemailattachment'+this.env.uid+props)); |
| | | if (attachment_win) { |
| | | setTimeout(function(){ attachment_win.focus(); }, 10); |
| | | if (this.open_window(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', true, true)) |
| | | break; |
| | | } |
| | | } |
| | | |
| | | this.goto_url('get', qstring+'&_download=1', false); |
| | |
| | | |
| | | case 'print': |
| | | if (uid = this.get_single_uid()) { |
| | | ref.printwin = window.open(this.env.comm_path+'&_action=print&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(this.env.safemode ? '&_safe=1' : '')); |
| | | ref.printwin = this.open_window(this.env.comm_path+'&_action=print&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(this.env.safemode ? '&_safe=1' : ''), true, true); |
| | | if (this.printwin) { |
| | | setTimeout(function(){ ref.printwin.focus(); }, 20); |
| | | if (this.env.action != 'show') |
| | | this.mark_message('read', uid); |
| | | } |
| | |
| | | break; |
| | | |
| | | case 'viewsource': |
| | | if (uid = this.get_single_uid()) { |
| | | ref.sourcewin = window.open(this.env.comm_path+'&_action=viewsource&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)); |
| | | if (this.sourcewin) |
| | | setTimeout(function(){ ref.sourcewin.focus(); }, 20); |
| | | } |
| | | if (uid = this.get_single_uid()) |
| | | this.open_window(this.env.comm_path+'&_action=viewsource&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox), true, true); |
| | | break; |
| | | |
| | | case 'download': |
| | |
| | | if (typeof cmd === 'string') { |
| | | this.commands[cmd] = enable; |
| | | this.set_button(cmd, (enable ? 'act' : 'pas')); |
| | | this.triggerEvent('enable-command', {command: cmd, status: enable}); |
| | | } |
| | | // push array elements into commands array |
| | | else { |
| | |
| | | |
| | | // start timer for message preview (wait for double click) |
| | | if (selected && this.env.contentframe && !list.multi_selecting && !this.dummy_select) |
| | | this.preview_timer = setTimeout(function(){ ref.msglist_get_preview(); }, 200); |
| | | this.preview_timer = setTimeout(function() { ref.msglist_get_preview(); }, this.dblclick_time); |
| | | else if (this.env.contentframe) |
| | | this.show_contentframe(false); |
| | | }; |
| | |
| | | |
| | | var win = this.get_frame_window(this.env.contentframe); |
| | | |
| | | if (win && win.location.href.indexOf(this.env.blankpage)>=0) { |
| | | if (win && win.location.href.indexOf(this.env.blankpage) >= 0) { |
| | | if (this.preview_timer) |
| | | clearTimeout(this.preview_timer); |
| | | if (this.preview_read_timer) |
| | | clearTimeout(this.preview_read_timer); |
| | | this.preview_timer = setTimeout(function(){ ref.msglist_get_preview(); }, 200); |
| | | |
| | | this.preview_timer = setTimeout(function() { ref.msglist_get_preview(); }, this.dblclick_time); |
| | | } |
| | | }; |
| | | |
| | |
| | | { |
| | | if (this.preview_timer) |
| | | clearTimeout(this.preview_timer); |
| | | |
| | | if (this.preview_read_timer) |
| | | clearTimeout(this.preview_read_timer); |
| | | |
| | | var uid = list.get_single_selection(); |
| | | |
| | | if (uid && this.env.mailbox == this.env.drafts_mailbox) |
| | | this.open_compose_step({ _draft_uid: uid, _mbox: this.env.mailbox }); |
| | | else if (uid) |
| | |
| | | return 0; |
| | | }; |
| | | |
| | | this.open_window = function(url, width, height) |
| | | // open popup window |
| | | this.open_window = function(url, small, toolbar) |
| | | { |
| | | var dh = (window.outerHeight || 0) - (window.innerHeight || 0), |
| | | dw = (window.outerWidth || 0) - (window.innerWidth || 0), |
| | | sh = screen.availHeight || screen.height, |
| | | sw = screen.availWidth || screen.width, |
| | | w = Math.min(width, sw), |
| | | h = Math.min(height, sh), |
| | | l = Math.max(0, (sw - w) / 2 + (screen.left || 0)), |
| | | t = Math.max(0, (sh - h) / 2 + (screen.top || 0)), |
| | | wname = 'rcmextwin' + new Date().getTime(), |
| | | extwin = window.open(url + (url.match(/\?/) ? '&' : '?') + '_extwin=1', wname, |
| | | 'width='+(w-dw)+',height='+(h-dh)+',top='+t+',left='+l+',resizable=yes,toolbar=no,status=no,location=no'); |
| | | var wname = 'rcmextwin' + new Date().getTime(); |
| | | |
| | | url += (url.match(/\?/) ? '&' : '?') + '_extwin=1'; |
| | | |
| | | if (this.env.standard_windows) |
| | | extwin = window.open(url, wname); |
| | | else { |
| | | var win = this.is_framed() ? parent.window : window, |
| | | page = $(win), |
| | | page_width = page.width(), |
| | | page_height = bw.mz ? $('body', win).height() : page.height(), |
| | | w = Math.min(small ? this.env.popup_width_small : this.env.popup_width, page_width), |
| | | h = page_height, // always use same height |
| | | l = (win.screenLeft || win.screenX) + 20, |
| | | t = (win.screenTop || win.screenY) + 20, |
| | | extwin = window.open(url, wname, |
| | | 'width='+w+',height='+h+',top='+t+',left='+l+',resizable=yes,location=no,scrollbars=yes' |
| | | +(toolbar ? ',toolbar=yes,menubar=yes,status=yes' : ',toolbar=no,menubar=no,status=no')); |
| | | } |
| | | |
| | | // write loading... message to empty windows |
| | | if (!url && extwin.document) { |
| | |
| | | // focus window, delayed to bring to front |
| | | window.setTimeout(function() { extwin.focus(); }, 10); |
| | | |
| | | return wname; |
| | | return extwin; |
| | | }; |
| | | |
| | | |
| | |
| | | } |
| | | else { |
| | | if (!preview && this.env.message_extwin && !this.env.extwin) |
| | | this.open_window(this.env.comm_path+url, 1000, 1200); |
| | | this.open_window(this.env.comm_path+url, true); |
| | | else |
| | | this.location_href(this.env.comm_path+url, target, true); |
| | | |
| | |
| | | |
| | | // open new compose window |
| | | if (this.env.compose_extwin && !this.env.extwin) { |
| | | this.open_window(url, 1150, 900); |
| | | this.open_window(url); |
| | | } |
| | | else { |
| | | this.redirect(url); |
| | | window.resizeTo(Math.max(1150, $(window).width()), Math.max(900, $(window).height())); |
| | | if (this.env.extwin) |
| | | window.resizeTo(Math.max(this.env.popup_width, $(window).width()), $(window).height() + 24); |
| | | } |
| | | }; |
| | | |
| | |
| | | |
| | | this.compose_add_recipient = function(field) |
| | | { |
| | | var recipients = [], input = $('#_'+field); |
| | | var recipients = [], input = $('#_'+field), delim = this.env.recipients_delimiter; |
| | | |
| | | if (this.contact_list && this.contact_list.selection.length) { |
| | | for (var id, n=0; n < this.contact_list.selection.length; n++) { |
| | |
| | | } |
| | | |
| | | if (recipients.length && input.length) { |
| | | var oldval = input.val(); |
| | | input.val((oldval ? oldval + this.env.recipients_delimiter : '') + recipients.join(this.env.recipients_delimiter)); |
| | | var oldval = input.val(), rx = new RegExp(RegExp.escape(delim) + '\\s*$'); |
| | | if (oldval && !rx.test(oldval)) |
| | | oldval += delim + ' '; |
| | | input.val(oldval + recipients.join(delim + ' ') + delim + ' '); |
| | | this.triggerEvent('add-recipient', { field:field, recipients:recipients }); |
| | | } |
| | | }; |
| | |
| | | if (!show_sig) |
| | | show_sig = this.env.show_sig; |
| | | |
| | | var cursor_pos, p = -1, |
| | | var i, rx, cursor_pos, p = -1, |
| | | id = obj.options[obj.selectedIndex].value, |
| | | input_message = $("[name='_message']"), |
| | | message = input_message.val(), |
| | | is_html = ($("input[name='_is_html']").val() == '1'), |
| | | sig = this.env.identity; |
| | | sig = this.env.identity, |
| | | delim = this.env.recipients_delimiter, |
| | | headers = ['replyto', 'bcc']; |
| | | |
| | | // update reply-to/bcc fields with addresses defined in identities |
| | | for (i in headers) { |
| | | var key = headers[i], |
| | | old_val = sig && this.env.identities[sig] ? this.env.identities[sig][key] : '', |
| | | new_val = id && this.env.identities[id] ? this.env.identities[id][key] : '', |
| | | input = $('[name="_'+key+'"]'), input_val = input.val(); |
| | | |
| | | // remove old address(es) |
| | | if (old_val && input_val) { |
| | | rx = new RegExp('\\s*' + RegExp.escape(old_val) + '\\s*'); |
| | | input_val = input_val.replace(rx, ''); |
| | | } |
| | | |
| | | // cleanup |
| | | rx = new RegExp(RegExp.escape(delim) + '\\s*' + RegExp(delim), 'g'); |
| | | input_val = input_val.replace(rx, delim) |
| | | rx = new RegExp('^\\s*' + RegExp.escape(delim) + '\\s*$'); |
| | | input_val = input_val.replace(rx, '') |
| | | |
| | | // add new address(es) |
| | | if (new_val) { |
| | | rx = new RegExp(RegExp.escape(delim) + '\\s*$'); |
| | | if (input_val && !rx.test(input_val)) |
| | | input_val += delim + ' '; |
| | | input_val += new_val + delim + ' '; |
| | | } |
| | | |
| | | if (old_val || new_val) |
| | | input.val(input_val).change(); |
| | | } |
| | | |
| | | // enable manual signature insert |
| | | if (this.env.signatures && this.env.signatures[id]) { |
| | |
| | | var n, id, sid, ref = this, writable = false, |
| | | source = this.env.source ? this.env.address_sources[this.env.source] : null; |
| | | |
| | | // we don't have dblclick handler here, so use 200 instead of this.dblclick_time |
| | | if (id = list.get_single_selection()) |
| | | this.preview_timer = setTimeout(function(){ ref.load_contact(id, 'show'); }, 200); |
| | | else if (this.env.contentframe) |
| | |
| | | }; |
| | | |
| | | // open a jquery UI dialog with the given content |
| | | this.show_popup_dialog = function(html, title) |
| | | this.show_popup_dialog = function(html, title, buttons) |
| | | { |
| | | // forward call to parent window |
| | | if (this.is_framed()) { |
| | | parent.rcmail.show_popup_dialog(html, title); |
| | | parent.rcmail.show_popup_dialog(html, title, buttons); |
| | | return; |
| | | } |
| | | |
| | |
| | | .html(html) |
| | | .dialog({ |
| | | title: title, |
| | | buttons: buttons, |
| | | modal: true, |
| | | resizable: true, |
| | | width: 580, |
| | | width: 500, |
| | | close: function(event, ui) { $(this).remove() } |
| | | }); |
| | | |
| | | // resize and center popup |
| | | var win = $(window), w = win.width(), h = win.height(), |
| | | width = popup.width(), height = popup.height(); |
| | | popup.dialog('option', { height: Math.min(h-40, height+50), width: Math.min(w-20, width+50) }) |
| | | .dialog('option', 'position', ['center', 'center']); // only works in a separate call (!?) |
| | | // resize and center popup |
| | | var win = $(window), w = win.width(), h = win.height(), |
| | | width = popup.width(), height = popup.height(); |
| | | |
| | | popup.dialog('option', { |
| | | height: Math.min(h - 40, height + 75 + (buttons ? 50 : 0)), |
| | | width: Math.min(w - 20, width + 20) |
| | | }); |
| | | }; |
| | | |
| | | // enable/disable buttons for page shifting |
| | |
| | | |
| | | for (c=0, len=repl.length; c < len; c++) { |
| | | cell = document.createElement('td'); |
| | | cell.innerHTML = repl[c].html; |
| | | cell.innerHTML = repl[c].html || ''; |
| | | if (repl[c].id) cell.id = repl[c].id; |
| | | if (repl[c].className) cell.className = repl[c].className; |
| | | tr.appendChild(cell); |
| | |
| | | url: ref.url(ref.env.filedrop.action||'upload', { _id:ref.env.compose_id||ref.env.cid||'', _uploadid:ts, _remote:1 }), |
| | | contentType: formdata ? false : 'multipart/form-data; boundary=' + boundary, |
| | | processData: false, |
| | | timeout: 0, // disable default timeout set in ajaxSetup() |
| | | data: formdata || multipart, |
| | | headers: {'X-Roundcube-Request': ref.env.request_token}, |
| | | beforeSend: function(xhr, s) { if (!formdata && xhr.sendAsBinary) xhr.send = xhr.sendAsBinary; }, |
| | |
| | | else if (plugin.name && regex.test(plugin.name)) |
| | | return 1; |
| | | } |
| | | |
| | | // this will detect any pdf plugin including PDF.js in Firefox |
| | | var obj = document.createElement('OBJECT'); |
| | | obj.onload = function() { rcmail.env.browser_capabilities.pdf = 1; }; |
| | | obj.onerror = function() { rcmail.env.browser_capabilities.pdf = 0; }; |
| | | obj.style.display = 'none'; |
| | | obj.type = 'application/pdf'; |
| | | obj.data = 'program/resources/blank.pdf'; |
| | | document.body.appendChild(obj); |
| | | |
| | | return 0; |
| | | }; |