| | |
| | | // execute a specific command on the web client |
| | | this.command = function(command, props, obj, event) |
| | | { |
| | | var ret, uid, cid, url, flag; |
| | | var ret, uid, cid, url, flag, aborted = false; |
| | | |
| | | if (obj && obj.blur) |
| | | obj.blur(); |
| | |
| | | var form = this.gui_objects.messageform, |
| | | win = this.open_window(''); |
| | | |
| | | this.save_compose_form_local(); |
| | | $("input[name='_action']", form).val('compose'); |
| | | form.action = this.url('mail/compose', { _id: this.env.compose_id, _extwin: 1 }); |
| | | form.target = win.name; |
| | | form.submit(); |
| | | if (win) { |
| | | this.save_compose_form_local(); |
| | | $("input[name='_action']", form).val('compose'); |
| | | form.action = this.url('mail/compose', { _id: this.env.compose_id, _extwin: 1 }); |
| | | form.target = win.name; |
| | | form.submit(); |
| | | } |
| | | else { |
| | | // this.display_message(this.get_label('windowopenerror'), 'error'); |
| | | } |
| | | } |
| | | else { |
| | | this.open_window(this.env.permaurl, true); |
| | |
| | | // Reset the auto-save timer |
| | | clearTimeout(this.save_timer); |
| | | |
| | | this.upload_file(props || this.gui_objects.uploadform, 'upload'); |
| | | if (!this.upload_file(props || this.gui_objects.uploadform, 'upload')) { |
| | | alert(this.get_label('selectimportfile')); |
| | | aborted = true; |
| | | } |
| | | break; |
| | | |
| | | case 'insert-sig': |
| | |
| | | |
| | | case 'import-messages': |
| | | var form = props || this.gui_objects.importform; |
| | | $('input[name="_unlock"]', form).val(this.set_busy(true, 'importwait')); |
| | | this.upload_file(form, 'import'); |
| | | var importlock = this.set_busy(true, 'importwait'); |
| | | $('input[name="_unlock"]', form).val(importlock); |
| | | if (!this.upload_file(form, 'import')) { |
| | | this.set_busy(false, null, importlock); |
| | | alert(this.get_label('selectimportfile')); |
| | | aborted = true; |
| | | } |
| | | break; |
| | | |
| | | case 'import': |
| | |
| | | var file = document.getElementById('rcmimportfile'); |
| | | if (file && !file.value) { |
| | | alert(this.get_label('selectimportfile')); |
| | | aborted = true; |
| | | break; |
| | | } |
| | | this.gui_objects.importform.submit(); |
| | |
| | | break; |
| | | } |
| | | |
| | | if (this.triggerEvent('after'+command, props) === false) |
| | | if (!aborted && this.triggerEvent('after'+command, props) === false) |
| | | ret = false; |
| | | this.triggerEvent('actionafter', {props:props, action:command}); |
| | | this.triggerEvent('actionafter', { props:props, action:command, aborted:aborted }); |
| | | |
| | | return ret === false ? false : obj ? false : true; |
| | | }; |
| | |
| | | |
| | | this.drag_end = function(e) |
| | | { |
| | | this.drag_active = false; |
| | | this.env.last_folder_target = null; |
| | | var list, model; |
| | | |
| | | if (this.treelist) |
| | | this.treelist.drag_end(); |
| | | |
| | | // execute drag & drop action when mouse was released |
| | | if (list = this.message_list) |
| | | model = this.env.mailboxes; |
| | | else if (list = this.contact_list) |
| | | model = this.env.contactfolders; |
| | | |
| | | if (this.drag_active && model && this.env.last_folder_target) { |
| | | var target = model[this.env.last_folder_target]; |
| | | list.draglayer.hide(); |
| | | |
| | | if (this.contact_list) { |
| | | if (!this.contacts_drag_menu(e, target)) |
| | | this.command('move', target); |
| | | } |
| | | else if (!this.drag_menu(e, target)) |
| | | this.command('move', target); |
| | | } |
| | | |
| | | this.drag_active = false; |
| | | this.env.last_folder_target = null; |
| | | }; |
| | | |
| | | this.drag_move = function(e) |
| | |
| | | |
| | | this.doc_mouse_up = function(e) |
| | | { |
| | | var model, list, id; |
| | | var list, id; |
| | | |
| | | // ignore event if jquery UI dialog is open |
| | | if ($(rcube_event.get_target(e)).closest('.ui-dialog, .ui-widget-overlay').length) |
| | | return; |
| | | |
| | | if (list = this.message_list) |
| | | model = this.env.mailboxes; |
| | | else if (list = this.contact_list) |
| | | model = this.env.contactfolders; |
| | | else if (this.ksearch_value) |
| | | this.ksearch_blur(); |
| | | |
| | | list = this.message_list || this.contact_list; |
| | | if (list && !rcube_mouse_is_over(e, list.list.parentNode)) |
| | | list.blur(); |
| | | |
| | | // handle mouse release when dragging |
| | | if (this.drag_active && model && this.env.last_folder_target) { |
| | | var target = model[this.env.last_folder_target]; |
| | | |
| | | this.env.last_folder_target = null; |
| | | list.draglayer.hide(); |
| | | this.drag_end(e); |
| | | |
| | | if (this.contact_list) { |
| | | if (!this.contacts_drag_menu(e, target)) |
| | | this.command('move', target); |
| | | } |
| | | else if (!this.drag_menu(e, target)) |
| | | this.command('move', target); |
| | | } |
| | | |
| | | // reset 'pressed' buttons |
| | | if (this.buttons_sel) { |
| | |
| | | tree += '<span id="msgicn'+uid+'" class="'+css_class+'"> </span>'; |
| | | row.className = row_class; |
| | | |
| | | // build subject link |
| | | if (!bw.ie && cols.subject) { |
| | | // build subject link |
| | | if (cols.subject) { |
| | | var action = flags.mbox == this.env.drafts_mailbox ? 'compose' : 'show'; |
| | | var uid_param = flags.mbox == this.env.drafts_mailbox ? '_draft_uid' : '_uid'; |
| | | cols.subject = '<a href="./?_task=mail&_action='+action+'&_mbox='+urlencode(flags.mbox)+'&'+uid_param+'='+uid+'"'+ |
| | | ' onclick="return rcube_event.cancel(event)" onmouseover="rcube_webmail.long_subject_title(this,'+(message.depth+1)+')">'+cols.subject+'</a>'; |
| | | ' onclick="return rcube_event.cancel(event)" onmouseover="rcube_webmail.long_subject_title(this,'+(message.depth+1)+')"><span>'+cols.subject+'</span></a>'; |
| | | } |
| | | |
| | | // add each submitted col |
| | |
| | | if (preview && this.message_list && this.message_list.rows[id] && this.message_list.rows[id].unread && this.env.preview_pane_mark_read >= 0) { |
| | | this.preview_read_timer = setTimeout(function() { |
| | | ref.set_message(id, 'unread', false); |
| | | ref.update_thread_root(id, 'read'); |
| | | if (ref.env.unread_counts[ref.env.mailbox]) { |
| | | ref.env.unread_counts[ref.env.mailbox] -= 1; |
| | | ref.set_unread_count(ref.env.mailbox, ref.env.unread_counts[ref.env.mailbox], ref.env.mailbox == 'INBOX'); |
| | |
| | | if (!row) |
| | | return false; |
| | | |
| | | if (flag == 'unread') |
| | | if (flag == 'unread') { |
| | | if (row.unread != status) |
| | | this.update_thread_root(uid, status ? 'unread' : 'read'); |
| | | row.unread = status; |
| | | } |
| | | else if(flag == 'deleted') |
| | | row.deleted = status; |
| | | else if (flag == 'replied') |
| | |
| | | this.set_message(a_uids[i], 'unread', (flag == 'unread' ? true : false)); |
| | | |
| | | this.http_post('mark', post_data, lock); |
| | | |
| | | for (i=0; i<len; i++) |
| | | this.update_thread_root(a_uids[i], flag); |
| | | }; |
| | | |
| | | // set image to flagged or unflagged |
| | |
| | | |
| | | // close compose step in opener |
| | | if (opener_rc && opener_rc.env.action == 'compose') { |
| | | setTimeout(function(){ opener.history.back(); }, 100); |
| | | setTimeout(function(){ |
| | | if (opener.history.length > 1) |
| | | opener.history.back(); |
| | | else |
| | | opener_rc.redirect(opener_rc.get_task_url('mail')); |
| | | }, 100); |
| | | this.env.opened_extwin = true; |
| | | } |
| | | |
| | |
| | | } |
| | | // skip records from 'other' drafts |
| | | if (this.env.draft_id && formdata.draft_id && formdata.draft_id != this.env.draft_id) { |
| | | continue; |
| | | } |
| | | // skip records on reply |
| | | if (this.env.reply_msgid && formdata.reply_msgid != this.env.reply_msgid) { |
| | | continue; |
| | | } |
| | | // show dialog asking to restore the message |
| | |
| | | if ($("input[name='_is_html']").val() == '1') { |
| | | var editor = tinyMCE.get(this.env.composebody); |
| | | editor.getWin().focus(); // correct focus in IE & Chrome |
| | | editor.selection.setContent(insert, { format:'text' }); |
| | | editor.selection.setContent(this.quote_html(insert).replace(/\r?\n/g, '<br/>'), { format:'text' }); |
| | | } |
| | | // replace selection in compose textarea |
| | | else { |
| | |
| | | { |
| | | var rc; |
| | | |
| | | if (!this.env.draft_id && id && (rc = this.opener())) { |
| | | // refresh the drafts folder in opener window |
| | | if (rc.env.task == 'mail' && rc.env.action == '' && rc.env.mailbox == this.env.drafts_mailbox) |
| | | rc.command('checkmail'); |
| | | if (id && id != this.env.draft_id) { |
| | | if (rc = this.opener()) { |
| | | // refresh the drafts folder in opener window |
| | | if (rc.env.task == 'mail' && rc.env.action == '' && rc.env.mailbox == this.env.drafts_mailbox) |
| | | rc.command('checkmail'); |
| | | } |
| | | |
| | | this.env.draft_id = id; |
| | | $("input[name='_draft_saveid']").val(id); |
| | | |
| | | // reset history of hidden iframe used for saving draft (#1489643) |
| | | if (window.frames['savetarget'] && window.frames['savetarget'].history) { |
| | | window.frames['savetarget'].history.back(); |
| | | } |
| | | } |
| | | |
| | | this.env.draft_id = id; |
| | | $("input[name='_draft_saveid']").val(id); |
| | | |
| | | // always remove local copy upon saving as draft |
| | | this.remove_compose_data(this.env.compose_id); |
| | | }; |
| | | |
| | |
| | | |
| | | if (this.env.draft_id) { |
| | | formdata.draft_id = this.env.draft_id; |
| | | } |
| | | if (this.env.reply_msgid) { |
| | | formdata.reply_msgid = this.env.reply_msgid; |
| | | } |
| | | |
| | | $('input, select, textarea', this.gui_objects.messageform).each(function(i, elem) { |
| | |
| | | if (numfiles) { |
| | | if (this.env.max_filesize && this.env.filesizeerror && size > this.env.max_filesize) { |
| | | this.display_message(this.env.filesizeerror, 'error'); |
| | | return; |
| | | return false; |
| | | } |
| | | |
| | | var frame_name = this.async_upload_form(form, action || 'upload', function(e) { |
| | |
| | | if (this.env.upload_progress_time) { |
| | | this.upload_progress_start('upload', ts); |
| | | } |
| | | |
| | | // set reference to the form object |
| | | this.gui_objects.attachmentform = form; |
| | | return true; |
| | | } |
| | | |
| | | // set reference to the form object |
| | | this.gui_objects.attachmentform = form; |
| | | return true; |
| | | return false; |
| | | }; |
| | | |
| | | // add file name to attachment list |
| | |
| | | |
| | | this.remove_from_attachment_list = function(name) |
| | | { |
| | | delete this.env.attachments[name]; |
| | | $('#'+name).remove(); |
| | | if (this.env.attachments) { |
| | | delete this.env.attachments[name]; |
| | | $('#'+name).remove(); |
| | | } |
| | | }; |
| | | |
| | | this.remove_attachment = function(name) |
| | |
| | | { |
| | | var key = 'G'+prop.source+prop.id; |
| | | if (this.treelist.remove(key)) { |
| | | this.triggerEvent('group_delete', { source:prop.source, id:prop.id }); |
| | | delete this.env.contactfolders[key]; |
| | | delete this.env.contactgroups[key]; |
| | | } |
| | |
| | | // replace an existing table row with a new folder line (with subfolders) |
| | | this.replace_folder_row = function(oldfolder, newfolder, display_name, is_protected, class_name) |
| | | { |
| | | if (!this.gui_objects.subscriptionlist) |
| | | if (!this.gui_objects.subscriptionlist) { |
| | | if (this.is_framed) |
| | | return parent.rcmail.replace_folder_row(oldfolder, newfolder, display_name, is_protected, class_name); |
| | | return false; |
| | | } |
| | | |
| | | var i, n, len, name, dispname, oldrow, tmprow, row, level, |
| | | tbody = this.gui_objects.subscriptionlist.tBodies[0], |
| | |
| | | subscribed = $('input[name="_subscribed[]"]', $('#'+id)).prop('checked'), |
| | | // find subfolders of renamed folder |
| | | list = this.get_subfolders(oldfolder); |
| | | |
| | | // no renaming, only update class_name |
| | | if (oldfolder == newfolder) { |
| | | $('#'+id).attr('class', class_name || ''); |
| | | this.subscription_list.focus(); |
| | | return; |
| | | } |
| | | |
| | | // replace an existing table row |
| | | this._remove_folder_row(id); |
| | |
| | | // disable/enable input buttons |
| | | if (button.type == 'input') { |
| | | button.status = state; |
| | | obj.disabled = !state; |
| | | obj.disabled = state == 'pas'; |
| | | } |
| | | else if (button.type == 'uibutton') { |
| | | $(obj).button('option', 'disabled', state == 'pas'); |
| | | } |
| | | } |
| | | }; |
| | |
| | | { |
| | | // forward call to parent window |
| | | if (this.is_framed()) { |
| | | return parent.rcmail.show_popup_dialog(html, title, buttons); |
| | | return parent.rcmail.show_popup_dialog(html, title, buttons, options); |
| | | } |
| | | |
| | | var popup = $('<div class="popup">') |
| | |
| | | |
| | | popup.dialog('option', { |
| | | height: Math.min(h - 40, height + 75 + (buttons ? 50 : 0)), |
| | | width: Math.min(w - 20, width + 20) |
| | | width: Math.min(w - 20, width + 36) |
| | | }); |
| | | |
| | | return popup; |
| | |
| | | this.mark_folder = function(name, class_name, prefix, encode) |
| | | { |
| | | $(this.get_folder_li(name, prefix, encode)).addClass(class_name); |
| | | this.triggerEvent('markfolder', {folder: name, mark: class_name, status: true}); |
| | | }; |
| | | |
| | | // adds a class to selected folder |
| | | this.unmark_folder = function(name, class_name, prefix, encode) |
| | | { |
| | | $(this.get_folder_li(name, prefix, encode)).removeClass(class_name); |
| | | this.triggerEvent('markfolder', {folder: name, mark: class_name, status: false}); |
| | | }; |
| | | |
| | | // helper method to find a folder list item |
| | |
| | | this.element_position = function(element, obj) |
| | | { |
| | | var obj = $(obj), win = $(window), |
| | | width = obj.width(), |
| | | height = obj.height(), |
| | | width = obj.outerWidth(), |
| | | height = obj.outerHeight(), |
| | | menu_pos = obj.data('menu-pos'), |
| | | win_height = win.height(), |
| | | elem_height = $(element).height(), |
| | | elem_width = $(element).width(), |
| | | pos = obj.offset(), |
| | | top = pos.top, |
| | | left = pos.left + width; |
| | | |
| | | if (menu_pos == 'bottom') { |
| | | top += height; |
| | | left -= width; |
| | | } |
| | | else |
| | | left -= 5; |
| | | |
| | | if (top + elem_height > win_height) { |
| | | top -= elem_height - height; |
| | |
| | | else if (status == 'timeout') |
| | | this.display_message(this.get_label('requesttimedout'), 'error'); |
| | | else if (request.status == 0 && status != 'abort') |
| | | this.display_message(this.get_label('servererror') + ' (No connection)', 'error'); |
| | | this.display_message(this.get_label('connerror'), 'error'); |
| | | |
| | | // redirect to url specified in location header if not empty |
| | | var location_url = request.getResponseHeader("Location"); |
| | |
| | | try { |
| | | window.navigator.registerProtocolHandler('mailto', this.mailto_handler_uri(), name); |
| | | } |
| | | catch(e) {}; |
| | | catch(e) { |
| | | this.display_message(String(e), 'error'); |
| | | }; |
| | | }; |
| | | |
| | | this.check_protocol_handler = function(name, elem) |
| | | { |
| | | var nav = window.navigator; |
| | | if (!nav |
| | | || (typeof nav.registerProtocolHandler != 'function') |
| | | || ((typeof nav.isProtocolHandlerRegistered == 'function') |
| | | && nav.isProtocolHandlerRegistered('mailto', this.mailto_handler_uri()) == 'registered') |
| | | ) |
| | | $(elem).addClass('disabled'); |
| | | else |
| | | $(elem).click(function() { rcmail.register_protocol_handler(name); return false; }); |
| | | if (!nav || (typeof nav.registerProtocolHandler != 'function')) { |
| | | $(elem).addClass('disabled').click(function(){ return false; }); |
| | | } |
| | | else { |
| | | var status = null; |
| | | if (typeof nav.isProtocolHandlerRegistered == 'function') { |
| | | status = nav.isProtocolHandlerRegistered('mailto', this.mailto_handler_uri()); |
| | | if (status) |
| | | $(elem).parent().find('.mailtoprotohandler-status').html(status); |
| | | } |
| | | else { |
| | | $(elem).click(function() { rcmail.register_protocol_handler(name); return false; }); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // Checks browser capabilities eg. PDF support, TIF support |