| | |
| | | this.task = this.env.task; |
| | | |
| | | // check browser |
| | | if (!bw.dom || !bw.xmlhttp_test() || (bw.mz && bw.vendver < 1.9)) { |
| | | if (this.env.server_error != 409 && (!bw.dom || !bw.xmlhttp_test() || (bw.mz && bw.vendver < 1.9))) { |
| | | this.goto_url('error', '_code=0x199'); |
| | | return; |
| | | } |
| | |
| | | if (this.env.permaurl) |
| | | this.enable_command('permaurl', 'extwin', true); |
| | | |
| | | // initialize html editor |
| | | if (this.env.html_editor_init && window.rcmail_editor_init) { |
| | | rcmail_editor_init(this.env.html_editor_init); |
| | | } |
| | | |
| | | switch (this.task) { |
| | | |
| | | case 'mail': |
| | |
| | | multiselect:true, multiexpand:true, draggable:true, keyboard:true, |
| | | column_movable:this.env.col_movable, dblclick_time:this.dblclick_time |
| | | }); |
| | | this.message_list.row_init = function(o){ p.init_message_row(o); }; |
| | | this.message_list.addEventListener('dblclick', function(o){ p.msglist_dbl_click(o); }); |
| | | this.message_list.addEventListener('click', function(o){ p.msglist_click(o); }); |
| | | this.message_list.addEventListener('keypress', function(o){ p.msglist_keypress(o); }); |
| | | this.message_list.addEventListener('select', function(o){ p.msglist_select(o); }); |
| | | this.message_list.addEventListener('dragstart', function(o){ p.drag_start(o); }); |
| | | this.message_list.addEventListener('dragmove', function(e){ p.drag_move(e); }); |
| | | this.message_list.addEventListener('dragend', function(e){ p.drag_end(e); }); |
| | | this.message_list.addEventListener('expandcollapse', function(e){ p.msglist_expand(e); }); |
| | | this.message_list.addEventListener('column_replace', function(e){ p.msglist_set_coltypes(e); }); |
| | | this.message_list.addEventListener('listupdate', function(e){ p.triggerEvent('listupdate', e); }); |
| | | this.message_list |
| | | .addEventListener('initrow', function(o) { p.init_message_row(o); }) |
| | | .addEventListener('dblclick', function(o) { p.msglist_dbl_click(o); }) |
| | | .addEventListener('click', function(o) { p.msglist_click(o); }) |
| | | .addEventListener('keypress', function(o) { p.msglist_keypress(o); }) |
| | | .addEventListener('select', function(o) { p.msglist_select(o); }) |
| | | .addEventListener('dragstart', function(o) { p.drag_start(o); }) |
| | | .addEventListener('dragmove', function(e) { p.drag_move(e); }) |
| | | .addEventListener('dragend', function(e) { p.drag_end(e); }) |
| | | .addEventListener('expandcollapse', function(o) { p.msglist_expand(o); }) |
| | | .addEventListener('column_replace', function(o) { p.msglist_set_coltypes(o); }) |
| | | .addEventListener('listupdate', function(o) { p.triggerEvent('listupdate', o); }) |
| | | .init(); |
| | | |
| | | document.onmouseup = function(e){ return p.doc_mouse_up(e); }; |
| | | this.gui_objects.messagelist.parentNode.onmousedown = function(e){ return p.click_on_list(e); }; |
| | | |
| | | this.message_list.init(); |
| | | this.enable_command('toggle_status', 'toggle_flag', 'sort', true); |
| | | |
| | | // load messages |
| | |
| | | if (this.gui_objects.contactslist) { |
| | | this.contact_list = new rcube_list_widget(this.gui_objects.contactslist, |
| | | { multiselect:true, draggable:false, keyboard:false }); |
| | | this.contact_list.row_init = function(row){ p.triggerEvent('insertrow', { cid:row.uid, row:row }); }; |
| | | this.contact_list.addEventListener('select', function(o){ ref.compose_recipient_select(o); }); |
| | | this.contact_list.addEventListener('dblclick', function(o){ ref.compose_add_recipient('to'); }); |
| | | this.contact_list.init(); |
| | | this.contact_list |
| | | .addEventListener('initrow', function(o) { p.triggerEvent('insertrow', { cid:o.uid, row:o }); }) |
| | | .addEventListener('select', function(o) { ref.compose_recipient_select(o); }) |
| | | .addEventListener('dblclick', function(o) { ref.compose_add_recipient('to'); }) |
| | | .init(); |
| | | } |
| | | |
| | | if (this.gui_objects.addressbookslist) { |
| | |
| | | if (this.gui_objects.contactslist) { |
| | | this.contact_list = new rcube_list_widget(this.gui_objects.contactslist, |
| | | {multiselect:true, draggable:this.gui_objects.folderlist?true:false, keyboard:true}); |
| | | this.contact_list.row_init = function(row){ p.triggerEvent('insertrow', { cid:row.uid, row:row }); }; |
| | | this.contact_list.addEventListener('keypress', function(o){ p.contactlist_keypress(o); }); |
| | | this.contact_list.addEventListener('select', function(o){ p.contactlist_select(o); }); |
| | | this.contact_list.addEventListener('dragstart', function(o){ p.drag_start(o); }); |
| | | this.contact_list.addEventListener('dragmove', function(e){ p.drag_move(e); }); |
| | | this.contact_list.addEventListener('dragend', function(e){ p.drag_end(e); }); |
| | | this.contact_list.init(); |
| | | this.contact_list |
| | | .addEventListener('initrow', function(o) { p.triggerEvent('insertrow', { cid:o.uid, row:o }); }) |
| | | .addEventListener('keypress', function(o) { p.contactlist_keypress(o); }) |
| | | .addEventListener('select', function(o) { p.contactlist_select(o); }) |
| | | .addEventListener('dragstart', function(o) { p.drag_start(o); }) |
| | | .addEventListener('dragmove', function(e) { p.drag_move(e); }) |
| | | .addEventListener('dragend', function(e) { p.drag_end(e); }) |
| | | .init(); |
| | | |
| | | if (this.env.cid) |
| | | this.contact_list.highlight_row(this.env.cid); |
| | |
| | | } |
| | | |
| | | if (this.gui_objects.identitieslist) { |
| | | this.identity_list = new rcube_list_widget(this.gui_objects.identitieslist, {multiselect:false, draggable:false, keyboard:false}); |
| | | this.identity_list.addEventListener('select', function(o){ p.identity_select(o); }); |
| | | this.identity_list.init(); |
| | | this.identity_list.focus(); |
| | | this.identity_list = new rcube_list_widget(this.gui_objects.identitieslist, |
| | | {multiselect:false, draggable:false, keyboard:false}); |
| | | this.identity_list |
| | | .addEventListener('select', function(o) { p.identity_select(o); }) |
| | | .init() |
| | | .focus(); |
| | | |
| | | if (this.env.iid) |
| | | this.identity_list.highlight_row(this.env.iid); |
| | | } |
| | | else if (this.gui_objects.sectionslist) { |
| | | this.sections_list = new rcube_list_widget(this.gui_objects.sectionslist, {multiselect:false, draggable:false, keyboard:false}); |
| | | this.sections_list.addEventListener('select', function(o){ p.section_select(o); }); |
| | | this.sections_list.init(); |
| | | this.sections_list.focus(); |
| | | this.sections_list |
| | | .addEventListener('select', function(o) { p.section_select(o); }) |
| | | .init() |
| | | .focus(); |
| | | } |
| | | else if (this.gui_objects.subscriptionlist) { |
| | | this.init_subscription_list(); |
| | | } |
| | | else if (this.gui_objects.responseslist) { |
| | | this.responses_list = new rcube_list_widget(this.gui_objects.responseslist, {multiselect:false, draggable:false, keyboard:false}); |
| | | this.responses_list.addEventListener('select', function(list) { |
| | | var win, id = list.get_single_selection(); |
| | | p.enable_command('delete', !!id && $.inArray(id, p.env.readonly_responses) < 0); |
| | | if (id && (win = p.get_frame_window(p.env.contentframe))) { |
| | | p.set_busy(true); |
| | | p.location_href({ _action:'edit-response', _key:id, _framed:1 }, win); |
| | | } |
| | | }); |
| | | this.responses_list.init(); |
| | | this.responses_list.focus(); |
| | | this.responses_list |
| | | .addEventListener('select', function(list) { |
| | | var win, id = list.get_single_selection(); |
| | | p.enable_command('delete', !!id && $.inArray(id, p.env.readonly_responses) < 0); |
| | | if (id && (win = p.get_frame_window(p.env.contentframe))) { |
| | | p.set_busy(true); |
| | | p.location_href({ _action:'edit-response', _key:id, _framed:1 }, win); |
| | | } |
| | | }) |
| | | .init() |
| | | .focus(); |
| | | } |
| | | |
| | | break; |
| | |
| | | id_prefix: 'rcmli', |
| | | id_encode: this.html_identifier_encode, |
| | | id_decode: this.html_identifier_decode, |
| | | check_droptarget: function(node){ return !node.virtual && ref.check_droptarget(node.id) } |
| | | check_droptarget: function(node) { return !node.virtual && ref.check_droptarget(node.id) } |
| | | }); |
| | | this.treelist.addEventListener('collapse', function(node){ ref.folder_collapsed(node) }); |
| | | this.treelist.addEventListener('expand', function(node){ ref.folder_collapsed(node) }); |
| | | this.treelist.addEventListener('select', function(node){ ref.triggerEvent('selectfolder', { folder:node.id, prefix:'rcmli' }) }); |
| | | this.treelist |
| | | .addEventListener('collapse', function(node) { ref.folder_collapsed(node) }) |
| | | .addEventListener('expand', function(node) { ref.folder_collapsed(node) }) |
| | | .addEventListener('select', function(node) { ref.triggerEvent('selectfolder', { folder:node.id, prefix:'rcmli' }) }); |
| | | } |
| | | } |
| | | |
| | |
| | | // 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(); |
| | |
| | | |
| | | // remove copy from local storage if compose screen is left intentionally |
| | | this.remove_compose_data(this.env.compose_id); |
| | | this.compose_skip_unsavedcheck = true; |
| | | } |
| | | |
| | | // process external commands |
| | |
| | | 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(); |
| | | this.compose_skip_unsavedcheck = true; |
| | | $("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); |
| | |
| | | if (this.task == 'mail') { |
| | | url._mbox = this.env.mailbox; |
| | | if (props) |
| | | url._to = props; |
| | | url._to = props; |
| | | // also send search request so we can go back to search result after message is sent |
| | | if (this.env.search_request) |
| | | url._search = this.env.search_request; |
| | |
| | | break; |
| | | } |
| | | } |
| | | else if (props) |
| | | else if (props && typeof props == 'string') { |
| | | url._to = props; |
| | | } |
| | | else if (props && typeof props == 'object') { |
| | | $.extend(url, props); |
| | | } |
| | | |
| | | this.open_compose_step(url); |
| | | break; |
| | |
| | | // Reset the auto-save timer |
| | | clearTimeout(this.save_timer); |
| | | |
| | | this.upload_file(props || this.gui_objects.uploadform, 'upload'); |
| | | if (!(flag = this.upload_file(props || this.gui_objects.uploadform, 'upload'))) { |
| | | if (flag !== false) |
| | | alert(this.get_label('selectimportfile')); |
| | | aborted = true; |
| | | } |
| | | break; |
| | | |
| | | case 'insert-sig': |
| | |
| | | break; |
| | | |
| | | 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 form = props || this.gui_objects.importform, |
| | | importlock = this.set_busy(true, 'importwait'); |
| | | |
| | | $('input[name="_unlock"]', form).val(importlock); |
| | | |
| | | if (!(flag = this.upload_file(form, 'import'))) { |
| | | this.set_busy(false, null, importlock); |
| | | if (flag !== false) |
| | | 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; |
| | | }; |
| | |
| | | var url = this.get_task_url(task); |
| | | if (task == 'mail') |
| | | url += '&_mbox=INBOX'; |
| | | else if (task == 'logout') |
| | | else if (task == 'logout' && !this.env.server_error) |
| | | this.clear_compose_data(); |
| | | |
| | | this.redirect(url); |
| | |
| | | |
| | | 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 |
| | | for (n in this.env.coltypes) { |
| | | c = this.env.coltypes[n]; |
| | | col = { className: String(c).toLowerCase() }; |
| | | col = {className: String(c).toLowerCase(), events:{}}; |
| | | |
| | | if (c == 'flag') { |
| | | css_class = (flags.flagged ? 'flagged' : 'unflagged'); |
| | |
| | | else if (c == 'threads') |
| | | html = expando; |
| | | else if (c == 'subject') { |
| | | if (bw.ie) { |
| | | col.onmouseover = function() { rcube_webmail.long_subject_title_ex(this, message.depth+1); }; |
| | | if (bw.ie8) |
| | | tree = '<span></span>' + tree; // #1487821 |
| | | } |
| | | if (bw.ie) |
| | | col.events.mouseover = function() { rcube_webmail.long_subject_title_ex(this); }; |
| | | html = tree + cols[c]; |
| | | } |
| | | else if (c == 'priority') { |
| | |
| | | this.location_href(this.env.comm_path+url, target, true); |
| | | |
| | | // mark as read and change mbox unread counter |
| | | if (preview && this.message_list && this.message_list.rows[id] && this.message_list.rows[id].unread && this.env.preview_pane_mark_read >= 0) { |
| | | 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 (ref.env.preview_pane_mark_read > 0) |
| | | ref.http_post('mark', {_uid: id, _flag: 'read', _quiet: 1}); |
| | | ref.set_unread_message(id, ref.env.mailbox); |
| | | ref.http_post('mark', {_uid: id, _flag: 'read', _quiet: 1}); |
| | | }, this.env.preview_pane_mark_read * 1000); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // update message status and unread counter after marking a message as read |
| | | this.set_unread_message = function(id, folder) |
| | | { |
| | | var self = this; |
| | | |
| | | // find window with messages list |
| | | if (!self.message_list) |
| | | self = self.opener(); |
| | | |
| | | if (!self && window.parent) |
| | | self = parent.rcmail; |
| | | |
| | | if (!self || !self.message_list) |
| | | return; |
| | | |
| | | self.set_message(id, 'unread', false); |
| | | |
| | | if (self.env.unread_counts[folder] > 0) { |
| | | self.env.unread_counts[folder] -= 1; |
| | | self.set_unread_count(folder, self.env.unread_counts[folder], folder == 'INBOX'); |
| | | } |
| | | }; |
| | | |
| | |
| | | var lock = this.set_busy(true, 'checkingmail'), |
| | | params = this.check_recent_params(); |
| | | |
| | | this.http_request('check-recent', params, lock); |
| | | this.http_post('check-recent', params, lock); |
| | | }; |
| | | |
| | | // list messages of a specific mailbox using filter |
| | |
| | | // expand all threads with unread children |
| | | this.expand_unread = function() |
| | | { |
| | | var r, tbody = this.gui_objects.messagelist.tBodies[0], |
| | | var r, tbody = this.message_list.tbody, |
| | | new_row = tbody.firstChild; |
| | | |
| | | while (new_row) { |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // check for locally stored compose data |
| | | if (window.localStorage) { |
| | | var index = this.local_storage_get_item('compose.index', []); |
| | | |
| | | for (var key, i = 0; i < index.length; i++) { |
| | | key = index[i], formdata = this.local_storage_get_item('compose.' + key, null, true); |
| | | if (!formdata) { |
| | | continue; |
| | | } |
| | | // restore saved copy of current compose_id |
| | | if (formdata.changed && key == this.env.compose_id) { |
| | | this.restore_compose_form(key, html_mode); |
| | | break; |
| | | } |
| | | // skip records from 'other' drafts |
| | | if (this.env.draft_id && formdata.draft_id && formdata.draft_id != this.env.draft_id) { |
| | | continue; |
| | | } |
| | | // show dialog asking to restore the message |
| | | if (formdata.changed && formdata.session != this.env.session_id) { |
| | | this.show_popup_dialog( |
| | | this.get_label('restoresavedcomposedata') |
| | | .replace('$date', new Date(formdata.changed).toLocaleString()) |
| | | .replace('$subject', formdata._subject) |
| | | .replace(/\n/g, '<br/>'), |
| | | this.get_label('restoremessage'), |
| | | [{ |
| | | text: this.get_label('restore'), |
| | | click: function(){ |
| | | ref.restore_compose_form(key, html_mode); |
| | | ref.remove_compose_data(key); // remove old copy |
| | | ref.save_compose_form_local(); // save under current compose_id |
| | | $(this).dialog('close'); |
| | | } |
| | | }, |
| | | { |
| | | text: this.get_label('delete'), |
| | | click: function(){ |
| | | ref.remove_compose_data(key); |
| | | $(this).dialog('close'); |
| | | } |
| | | }, |
| | | { |
| | | text: this.get_label('ignore'), |
| | | click: function(){ |
| | | $(this).dialog('close'); |
| | | } |
| | | }] |
| | | ); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | this.compose_restore_dialog(0, html_mode) |
| | | |
| | | if (input_to.val() == '') |
| | | input_to.focus(); |
| | |
| | | // start the auto-save timer |
| | | this.auto_save_start(); |
| | | }; |
| | | |
| | | this.compose_restore_dialog = function(j, html_mode) |
| | | { |
| | | var i, key, formdata, index = this.local_storage_get_item('compose.index', []); |
| | | |
| | | var show_next = function(i) { |
| | | if (++i < index.length) |
| | | ref.compose_restore_dialog(i, html_mode) |
| | | } |
| | | |
| | | for (i = j || 0; i < index.length; i++) { |
| | | key = index[i]; |
| | | formdata = this.local_storage_get_item('compose.' + key, null, true); |
| | | if (!formdata) { |
| | | continue; |
| | | } |
| | | // restore saved copy of current compose_id |
| | | if (formdata.changed && key == this.env.compose_id) { |
| | | this.restore_compose_form(key, html_mode); |
| | | break; |
| | | } |
| | | // 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 (formdata.changed && formdata.session != this.env.session_id) { |
| | | this.show_popup_dialog( |
| | | this.get_label('restoresavedcomposedata') |
| | | .replace('$date', new Date(formdata.changed).toLocaleString()) |
| | | .replace('$subject', formdata._subject) |
| | | .replace(/\n/g, '<br/>'), |
| | | this.get_label('restoremessage'), |
| | | [{ |
| | | text: this.get_label('restore'), |
| | | click: function(){ |
| | | ref.restore_compose_form(key, html_mode); |
| | | ref.remove_compose_data(key); // remove old copy |
| | | ref.save_compose_form_local(); // save under current compose_id |
| | | $(this).dialog('close'); |
| | | } |
| | | }, |
| | | { |
| | | text: this.get_label('delete'), |
| | | click: function(){ |
| | | ref.remove_compose_data(key); |
| | | $(this).dialog('close'); |
| | | show_next(i); |
| | | } |
| | | }, |
| | | { |
| | | text: this.get_label('ignore'), |
| | | click: function(){ |
| | | $(this).dialog('close'); |
| | | show_next(i); |
| | | } |
| | | }] |
| | | ); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.init_address_input_events = function(obj, props) |
| | | { |
| | |
| | | form._draft.value = draft ? '1' : ''; |
| | | form.action = this.add_url(form.action, '_unlock', msgid); |
| | | form.action = this.add_url(form.action, '_lang', lang); |
| | | form.action = this.add_url(form.action, '_framed', 1); |
| | | |
| | | // register timer to notify about connection timeout |
| | | this.submit_timer = setTimeout(function(){ |
| | |
| | | $(tinyMCE.get(props.id).getBody()).css('font-family', rcmail.env.default_font); |
| | | }, 500); |
| | | } |
| | | else { |
| | | var thisMCE = tinyMCE.get(props.id), existingHtml; |
| | | |
| | | if (existingHtml = thisMCE.getContent()) { |
| | | if (!confirm(this.get_label('editorwarning'))) { |
| | | return false; |
| | | } |
| | | this.html2plain(existingHtml, props.id); |
| | | } |
| | | else if (this.html2plain(tinyMCE.get(props.id).getContent(), props.id)) |
| | | tinyMCE.execCommand('mceRemoveControl', false, props.id); |
| | | } |
| | | |
| | | return true; |
| | | }; |
| | |
| | | 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 { |
| | |
| | | // submit delete request |
| | | if (key && confirm(this.get_label('deleteresponseconfirm'))) { |
| | | this.http_post('settings/delete-response', { _key: key }, false); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | }; |
| | | |
| | | this.stop_spellchecking = function() |
| | |
| | | { |
| | | 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) |
| | | // but don't do this on timer-triggered draft-autosaving (#1489789) |
| | | if (window.frames['savetarget'] && window.frames['savetarget'].history && !this.draft_autosave_submit) { |
| | | window.frames['savetarget'].history.back(); |
| | | } |
| | | |
| | | this.draft_autosave_submit = false; |
| | | } |
| | | |
| | | 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); |
| | | this.compose_skip_unsavedcheck = false; |
| | | }; |
| | | |
| | | this.auto_save_start = function() |
| | | { |
| | | if (this.env.draft_autosave) |
| | | this.save_timer = setTimeout(function(){ ref.command("savedraft"); }, this.env.draft_autosave * 1000); |
| | | if (this.env.draft_autosave) { |
| | | this.draft_autosave_submit = false; |
| | | this.save_timer = setTimeout(function(){ |
| | | ref.draft_autosave_submit = true; // set auto-saved flag (#1489789) |
| | | ref.command("savedraft"); |
| | | }, this.env.draft_autosave * 1000); |
| | | } |
| | | |
| | | // save compose form content to local storage every 5 seconds |
| | | if (!this.local_save_timer && window.localStorage) { |
| | |
| | | ref.compose_type_activity_last = ref.compose_type_activity; |
| | | } |
| | | }, 5000); |
| | | |
| | | $(window).unload(function() { |
| | | // remove copy from local storage if compose screen is left after warning |
| | | if (!ref.env.server_error) |
| | | ref.remove_compose_data(ref.env.compose_id); |
| | | }); |
| | | } |
| | | |
| | | // check for unsaved changes before leaving the compose page |
| | | if (!window.onbeforeunload) { |
| | | window.onbeforeunload = function() { |
| | | if (!ref.compose_skip_unsavedcheck && ref.cmp_hash != ref.compose_field_hash()) { |
| | | return ref.get_label('notsentwarning'); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | // Unlock interface now that saving is complete |
| | |
| | | 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) { |
| | | switch (elem.tagName.toLowerCase()) { |
| | |
| | | } |
| | | }); |
| | | |
| | | if (window.localStorage && !empty) { |
| | | if (!empty) { |
| | | var index = this.local_storage_get_item('compose.index', []), |
| | | key = this.env.compose_id; |
| | | |
| | | if ($.inArray(key, index) < 0) { |
| | | index.push(key); |
| | | } |
| | | this.local_storage_set_item('compose.' + key, formdata, true); |
| | | this.local_storage_set_item('compose.index', index); |
| | | if ($.inArray(key, index) < 0) { |
| | | index.push(key); |
| | | } |
| | | |
| | | this.local_storage_set_item('compose.' + key, formdata, true); |
| | | this.local_storage_set_item('compose.index', index); |
| | | } |
| | | }; |
| | | |
| | |
| | | // remove stored compose data from localStorage |
| | | this.remove_compose_data = function(key) |
| | | { |
| | | if (window.localStorage) { |
| | | var index = this.local_storage_get_item('compose.index', []); |
| | | var index = this.local_storage_get_item('compose.index', []); |
| | | |
| | | if ($.inArray(key, index) >= 0) { |
| | | this.local_storage_remove_item('compose.' + key); |
| | | this.local_storage_set_item('compose.index', $.grep(index, function(val,i) { return val != key; })); |
| | | } |
| | | if ($.inArray(key, index) >= 0) { |
| | | this.local_storage_remove_item('compose.' + key); |
| | | this.local_storage_set_item('compose.index', $.grep(index, function(val,i) { return val != key; })); |
| | | } |
| | | }; |
| | | |
| | | // clear all stored compose data of this user |
| | | this.clear_compose_data = function() |
| | | { |
| | | if (window.localStorage) { |
| | | var index = this.local_storage_get_item('compose.index', []); |
| | | var i, index = this.local_storage_get_item('compose.index', []); |
| | | |
| | | for (var i=0; i < index.length; i++) { |
| | | this.local_storage_remove_item('compose.' + index[i]); |
| | | } |
| | | this.local_storage_remove_item('compose.index'); |
| | | for (i=0; i < index.length; i++) { |
| | | this.local_storage_remove_item('compose.' + index[i]); |
| | | } |
| | | } |
| | | |
| | | this.local_storage_remove_item('compose.index'); |
| | | }; |
| | | |
| | | |
| | | this.change_identity = function(obj, show_sig) |
| | |
| | | if (!show_sig) |
| | | show_sig = this.env.show_sig; |
| | | |
| | | var id = obj.options[obj.selectedIndex].value; |
| | | |
| | | // enable manual signature insert |
| | | if (this.env.signatures && this.env.signatures[id]) { |
| | | this.enable_command('insert-sig', true); |
| | | this.env.compose_commands.push('insert-sig'); |
| | | } |
| | | else |
| | | this.enable_command('insert-sig', false); |
| | | |
| | | // first function execution |
| | | if (!this.env.identities_initialized) { |
| | | this.env.identities_initialized = true; |
| | |
| | | return; |
| | | } |
| | | |
| | | var i, rx, cursor_pos, p = -1, |
| | | id = obj.options[obj.selectedIndex].value, |
| | | var cursor_pos, p = -1, |
| | | input_message = $("[name='_message']"), |
| | | message = input_message.val(), |
| | | is_html = ($("input[name='_is_html']").val() == '1'), |
| | | sig = this.env.identity, |
| | | delim = this.env.recipients_separator, |
| | | rx_delim = RegExp.escape(delim), |
| | | headers = ['replyto', 'bcc']; |
| | | rx_delim = RegExp.escape(delim); |
| | | |
| | | // 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] : '', |
| | | $.each(['replyto', 'bcc'], function() { |
| | | var rx, key = this, |
| | | old_val = sig && ref.env.identities[sig] ? ref.env.identities[sig][key] : '', |
| | | new_val = id && ref.env.identities[id] ? ref.env.identities[id][key] : '', |
| | | input = $('[name="_'+key+'"]'), input_val = input.val(); |
| | | |
| | | // remove old address(es) |
| | |
| | | |
| | | if (old_val || new_val) |
| | | input.val(input_val).change(); |
| | | } |
| | | |
| | | // enable manual signature insert |
| | | if (this.env.signatures && this.env.signatures[id]) { |
| | | this.enable_command('insert-sig', true); |
| | | this.env.compose_commands.push('insert-sig'); |
| | | } |
| | | else |
| | | this.enable_command('insert-sig', false); |
| | | }); |
| | | |
| | | if (!is_html) { |
| | | // remove the 'old' signature |
| | |
| | | this.upload_file = function(form, action) |
| | | { |
| | | if (!form) |
| | | return false; |
| | | return; |
| | | |
| | | // count files and size on capable browser |
| | | var size = 0, numfiles = 0; |
| | |
| | | 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; |
| | | } |
| | | }; |
| | | |
| | | // add file name to attachment list |
| | |
| | | li.attr('id', name) |
| | | .addClass(att.classname) |
| | | .html(att.html) |
| | | .on('mouseover', function() { rcube_webmail.long_subject_title_ex(this, 0); }); |
| | | .on('mouseover', function() { rcube_webmail.long_subject_title_ex(this); }); |
| | | |
| | | // replace indicator's li |
| | | if (upload_id && (indicator = document.getElementById(upload_id))) { |
| | |
| | | |
| | | 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) |
| | |
| | | this.sent_successfully = function(type, msg, folders) |
| | | { |
| | | this.display_message(msg, type); |
| | | this.compose_skip_unsavedcheck = true; |
| | | |
| | | if (this.env.extwin) { |
| | | var rc = this.opener(); |
| | | this.lock_form(this.gui_objects.messageform); |
| | | |
| | | var rc = this.opener(); |
| | | if (rc) { |
| | | rc.display_message(msg, type); |
| | | // refresh the folder where sent message was saved or replied message comes from |
| | | if (folders && rc.env.task == 'mail' && rc.env.action == '' && $.inArray(rc.env.mailbox, folders) >= 0) { |
| | | // @TODO: try with 'checkmail' here when #1485186 is fixed. See also #1489249. |
| | | rc.command('list'); |
| | | rc.command('checkmail'); |
| | | } |
| | | } |
| | | setTimeout(function(){ window.close() }, 1000); |
| | | |
| | | setTimeout(function() { window.close(); }, 1000); |
| | | } |
| | | else { |
| | | // before redirect we need to wait some time for Chrome (#1486177) |
| | | setTimeout(function(){ ref.list_mailbox(); }, 500); |
| | | setTimeout(function() { ref.list_mailbox(); }, 500); |
| | | } |
| | | }; |
| | | |
| | |
| | | this.ksearch_input.value = pre + insert + end; |
| | | |
| | | // set caret to insert pos |
| | | cpos = p+insert.length; |
| | | if (this.ksearch_input.setSelectionRange) |
| | | this.ksearch_input.setSelectionRange(cpos, cpos); |
| | | this.set_caret_pos(this.ksearch_input, p + insert.length); |
| | | |
| | | if (trigger) { |
| | | this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert }); |
| | |
| | | this.list_contacts = function(src, group, page) |
| | | { |
| | | var win, folder, url = {}, |
| | | refresh = src === undefined && group === undefined && page === undefined, |
| | | target = window; |
| | | |
| | | if (!src) |
| | |
| | | page = this.env.current_page = 1; |
| | | this.reset_qsearch(); |
| | | } |
| | | else if (group != this.env.group) |
| | | else if (!refresh && group != this.env.group) |
| | | page = this.env.current_page = 1; |
| | | |
| | | if (this.env.search_id) |
| | |
| | | if (action && (cid || action=='add') && !this.drag_active) { |
| | | if (this.env.group) |
| | | url._gid = this.env.group; |
| | | |
| | | if (this.env.search_request) |
| | | url._search = this.env.search_request; |
| | | |
| | | url._action = action; |
| | | url._source = this.env.source; |
| | |
| | | { |
| | | 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]; |
| | | } |
| | |
| | | id = this.env.iid ? this.env.iid : selection[0]; |
| | | |
| | | // submit request with appended token |
| | | if (confirm(this.get_label('deleteidentityconfirm'))) |
| | | this.goto_url('delete-identity', { _iid: id, _token: this.env.request_token }, true); |
| | | |
| | | return true; |
| | | if (id && confirm(this.get_label('deleteidentityconfirm'))) |
| | | this.http_post('settings/delete-identity', { _iid: id }, true); |
| | | }; |
| | | |
| | | this.update_identity_row = function(id, name, add) |
| | |
| | | frame.location.href = this.env.blankpage; |
| | | } |
| | | } |
| | | |
| | | this.enable_command('delete', false); |
| | | }; |
| | | |
| | | this.remove_identity = function(id) |
| | | { |
| | | var frame, list = this.identity_list, |
| | | rid = this.html_identifier(id); |
| | | |
| | | if (list && id) { |
| | | list.remove_row(rid); |
| | | if (this.env.contentframe && (frame = this.get_frame_window(this.env.contentframe))) { |
| | | frame.location.href = this.env.blankpage; |
| | | } |
| | | } |
| | | |
| | | this.enable_command('delete', false); |
| | | }; |
| | | |
| | | |
| | |
| | | |
| | | this.subscription_list = new rcube_list_widget(this.gui_objects.subscriptionlist, |
| | | {multiselect:false, draggable:true, keyboard:false, toggleselect:true}); |
| | | this.subscription_list.addEventListener('select', function(o){ p.subscription_select(o); }); |
| | | this.subscription_list.addEventListener('dragstart', function(o){ p.drag_active = true; }); |
| | | this.subscription_list.addEventListener('dragend', function(o){ p.subscription_move_folder(o); }); |
| | | this.subscription_list.row_init = function (row) { |
| | | row.obj.onmouseover = function() { p.focus_subscription(row.id); }; |
| | | row.obj.onmouseout = function() { p.unfocus_subscription(row.id); }; |
| | | }; |
| | | this.subscription_list.init(); |
| | | this.subscription_list |
| | | .addEventListener('select', function(o){ p.subscription_select(o); }) |
| | | .addEventListener('dragstart', function(o){ p.drag_active = true; }) |
| | | .addEventListener('dragend', function(o){ p.subscription_move_folder(o); }) |
| | | .addEventListener('initrow', function (row) { |
| | | row.obj.onmouseover = function() { p.focus_subscription(row.id); }; |
| | | row.obj.onmouseout = function() { p.unfocus_subscription(row.id); }; |
| | | }) |
| | | .init(); |
| | | |
| | | $('#mailboxroot') |
| | | .mouseover(function(){ p.focus_subscription(this.id); }) |
| | |
| | | // 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.env.quota_content = content; |
| | | }; |
| | | |
| | | // update trash folder state |
| | | this.set_trash_count = function(count) |
| | | { |
| | | this[(count ? 'un' : '') + 'mark_folder'](this.env.trash_mailbox, 'empty', '', true); |
| | | }; |
| | | |
| | | // update the mailboxlist |
| | | this.set_unread_count = function(mbox, count, set_title, mark) |
| | | { |
| | |
| | | |
| | | // fetch headers only once |
| | | if (!this.gui_objects.all_headers_box.innerHTML) { |
| | | var lock = this.display_message(this.get_label('loading'), 'loading'); |
| | | this.http_post('headers', {_uid: this.env.uid}, lock); |
| | | this.http_post('headers', {_uid: this.env.uid, _mbox: this.env.mailbox}, |
| | | this.display_message(this.get_label('loading'), 'loading') |
| | | ); |
| | | } |
| | | }; |
| | | |
| | |
| | | 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; |
| | |
| | | |
| | | this.html2plain = function(htmlText, id) |
| | | { |
| | | // warn the user (if converted content is not empty) |
| | | if (!htmlText || !(htmlText.replace(/<[^>]+>| |\s/g, '')).length) { |
| | | // without setTimeout() here, textarea is filled with initial (onload) content |
| | | setTimeout(function() { $('#'+id).val(''); }, 50); |
| | | return true; |
| | | } |
| | | |
| | | if (!confirm(this.get_label('editorwarning'))) |
| | | return false; |
| | | |
| | | var rcmail = this, |
| | | url = '?_task=utils&_action=html2text', |
| | | lock = this.set_busy(true, 'converting'); |
| | |
| | | error: function(o, status, err) { rcmail.http_error(o, status, err, lock); }, |
| | | success: function(data) { rcmail.set_busy(false, null, lock); $('#'+id).val(data); rcmail.log(data); } |
| | | }); |
| | | |
| | | return true; |
| | | }; |
| | | |
| | | this.plain2html = function(plain, id) |
| | |
| | | param[k] = query[k]; |
| | | } |
| | | |
| | | return base + '&' + $.param(param) + querystring; |
| | | return base + (base.indexOf('?') > -1 ? '&' : '?') + $.param(param) + querystring; |
| | | }; |
| | | |
| | | this.redirect = function(url, lock) |
| | |
| | | |
| | | this.goto_url = function(action, query, lock) |
| | | { |
| | | this.redirect(this.url(action, query)); |
| | | this.redirect(this.url(action, query), lock); |
| | | }; |
| | | |
| | | this.location_href = function(url, target, frame) |
| | |
| | | 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"); |
| | |
| | | // save message in local storage and do not redirect |
| | | if (this.env.action == 'compose') { |
| | | this.save_compose_form_local(); |
| | | this.compose_skip_unsavedcheck = true; |
| | | } |
| | | else if (redirect_url) { |
| | | window.setTimeout(function(){ ref.redirect(redirect_url, true); }, 2000); |
| | |
| | | this.env.lastrefresh = new Date(); |
| | | |
| | | // plugins should bind to 'requestrefresh' event to add own params |
| | | this.http_request('refresh', params, lock); |
| | | this.http_post('refresh', params, lock); |
| | | }; |
| | | |
| | | // returns check-recent request parameters |
| | |
| | | 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 |
| | |
| | | // wrapper for localStorage.getItem(key) |
| | | this.local_storage_get_item = function(key, deflt, encrypted) |
| | | { |
| | | var item; |
| | | |
| | | // TODO: add encryption |
| | | var item = localStorage.getItem(this.get_local_storage_prefix() + key); |
| | | try { |
| | | item = localStorage.getItem(this.get_local_storage_prefix() + key); |
| | | } |
| | | catch (e) { } |
| | | |
| | | return item !== null ? JSON.parse(item) : (deflt || null); |
| | | }; |
| | | |
| | | // wrapper for localStorage.setItem(key, data) |
| | | this.local_storage_set_item = function(key, data, encrypted) |
| | | { |
| | | // TODO: add encryption |
| | | return localStorage.setItem(this.get_local_storage_prefix() + key, JSON.stringify(data)); |
| | | // try/catch to handle no localStorage support, but also error |
| | | // in Safari-in-private-browsing-mode where localStorage exists |
| | | // but can't be used (#1489996) |
| | | try { |
| | | // TODO: add encryption |
| | | localStorage.setItem(this.get_local_storage_prefix() + key, JSON.stringify(data)); |
| | | return true; |
| | | } |
| | | catch (e) { |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | // wrapper for localStorage.removeItem(key) |
| | | this.local_storage_remove_item = function(key) |
| | | { |
| | | return localStorage.removeItem(this.get_local_storage_prefix() + key); |
| | | try { |
| | | localStorage.removeItem(this.get_local_storage_prefix() + key); |
| | | return true; |
| | | } |
| | | catch (e) { |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | } // end object rcube_webmail |
| | |
| | | } |
| | | }; |
| | | |
| | | rcube_webmail.long_subject_title_ex = function(elem, indent) |
| | | rcube_webmail.long_subject_title_ex = function(elem) |
| | | { |
| | | if (!elem.title) { |
| | | var $elem = $(elem), |
| | |
| | | w = tmp.width(); |
| | | |
| | | tmp.remove(); |
| | | if (w + indent * 15 > $elem.width()) |
| | | if (w + $('span.branch', $elem).width() * 15 > $elem.width()) |
| | | elem.title = txt; |
| | | } |
| | | }; |