| | |
| | | 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; |
| | | } |
| | |
| | | // Reset the auto-save timer |
| | | clearTimeout(this.save_timer); |
| | | |
| | | if (!this.upload_file(props || this.gui_objects.uploadform, 'upload')) { |
| | | alert(this.get_label('selectimportfile')); |
| | | if (!(flag = this.upload_file(props || this.gui_objects.uploadform, 'upload'))) { |
| | | if (flag !== false) |
| | | alert(this.get_label('selectimportfile')); |
| | | aborted = true; |
| | | } |
| | | break; |
| | |
| | | break; |
| | | |
| | | case 'import-messages': |
| | | var form = props || this.gui_objects.importform; |
| | | var importlock = this.set_busy(true, 'importwait'); |
| | | var form = props || this.gui_objects.importform, |
| | | importlock = this.set_busy(true, 'importwait'); |
| | | |
| | | $('input[name="_unlock"]', form).val(importlock); |
| | | if (!this.upload_file(form, 'import')) { |
| | | |
| | | if (!(flag = this.upload_file(form, 'import'))) { |
| | | this.set_busy(false, null, importlock); |
| | | alert(this.get_label('selectimportfile')); |
| | | if (flag !== false) |
| | | alert(this.get_label('selectimportfile')); |
| | | aborted = true; |
| | | } |
| | | break; |
| | |
| | | // 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); |
| | | 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 |
| | |
| | | $(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; |
| | | }; |
| | |
| | | $("input[name='_draft_saveid']").val(id); |
| | | |
| | | // reset history of hidden iframe used for saving draft (#1489643) |
| | | if (window.frames['savetarget'] && window.frames['savetarget'].history) { |
| | | // 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; |
| | | } |
| | | |
| | | // always remove local copy upon saving as draft |
| | |
| | | |
| | | 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) { |
| | |
| | | this.upload_file = function(form, action) |
| | | { |
| | | if (!form) |
| | | return false; |
| | | return; |
| | | |
| | | // count files and size on capable browser |
| | | var size = 0, numfiles = 0; |
| | |
| | | this.gui_objects.attachmentform = form; |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | }; |
| | | |
| | | // 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.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 }); |
| | |
| | | |
| | | // 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.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) |
| | |
| | | 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 |
| | |
| | | } |
| | | }; |
| | | |
| | | 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; |
| | | } |
| | | }; |