summaryrefslogtreecommitdiff
path: root/program/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'program/js/app.js')
-rw-r--r--program/js/app.js195
1 files changed, 128 insertions, 67 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 1cbc36a76..f548ad850 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -566,7 +566,7 @@ function rcube_webmail()
// 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();
@@ -652,11 +652,16 @@ function rcube_webmail()
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);
@@ -1064,7 +1069,10 @@ function rcube_webmail()
// 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':
@@ -1188,8 +1196,13 @@ function rcube_webmail()
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':
@@ -1197,6 +1210,7 @@ function rcube_webmail()
var file = document.getElementById('rcmimportfile');
if (file && !file.value) {
alert(this.get_label('selectimportfile'));
+ aborted = true;
break;
}
this.gui_objects.importform.submit();
@@ -1248,9 +1262,9 @@ function rcube_webmail()
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;
};
@@ -1450,11 +1464,31 @@ function rcube_webmail()
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)
@@ -1515,38 +1549,16 @@ function rcube_webmail()
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) {
for (id in this.buttons_sel)
@@ -1906,12 +1918,12 @@ function rcube_webmail()
tree += '<span id="msgicn'+row.id+'" class="'+css_class+'">&nbsp;</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+'='+urlencode(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
@@ -3113,7 +3125,12 @@ function rcube_webmail()
// 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;
}
@@ -3158,6 +3175,10 @@ function rcube_webmail()
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(
@@ -3409,7 +3430,7 @@ function rcube_webmail()
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 {
@@ -3633,8 +3654,14 @@ function rcube_webmail()
this.env.draft_id = id;
$("input[name='_draft_saveid']").val(id);
- this.remove_compose_data(this.env.compose_id);
+ // reset history of hidden iframe used for saving draft (#1489643)
+ if (window.frames['savetarget'] && window.frames['savetarget'].history) {
+ window.frames['savetarget'].history.back();
+ }
}
+
+ // always remove local copy upon saving as draft
+ this.remove_compose_data(this.env.compose_id);
};
this.auto_save_start = function()
@@ -3698,6 +3725,9 @@ function rcube_webmail()
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()) {
@@ -3977,7 +4007,7 @@ function rcube_webmail()
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) {
@@ -4011,11 +4041,13 @@ function rcube_webmail()
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
@@ -4057,8 +4089,10 @@ function rcube_webmail()
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)
@@ -4312,11 +4346,15 @@ function rcube_webmail()
this.ksearch_destroy();
// insert all members of a group
- if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].id) {
+ if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].type == 'group') {
insert += this.env.contacts[id].name + this.env.recipients_delimiter;
this.group2expand[this.env.contacts[id].id] = $.extend({ input: this.ksearch_input }, this.env.contacts[id]);
this.http_request('mail/group-expand', {_source: this.env.contacts[id].source, _gid: this.env.contacts[id].id}, false);
}
+ else if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].name) {
+ insert = this.env.contacts[id].name + this.env.recipients_delimiter;
+ trigger = true;
+ }
else if (typeof this.env.contacts[id] === 'string') {
insert = this.env.contacts[id] + this.env.recipients_delimiter;
trigger = true;
@@ -4330,7 +4368,7 @@ function rcube_webmail()
this.ksearch_input.setSelectionRange(cpos, cpos);
if (trigger) {
- this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert });
+ this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert, data:this.env.contacts[id] });
this.compose_type_activity++;
}
};
@@ -4417,7 +4455,7 @@ function rcube_webmail()
return;
// display search results
- var i, len, ul, li, text, init,
+ var i, len, ul, li, text, type, init,
value = this.ksearch_value,
maxlen = this.env.autocomplete_max ? this.env.autocomplete_max : 15;
@@ -4450,11 +4488,13 @@ function rcube_webmail()
if (results && (len = results.length)) {
for (i=0; i < len && maxlen > 0; i++) {
text = typeof results[i] === 'object' ? results[i].name : results[i];
+ type = typeof results[i] === 'object' ? results[i].type : '';
li = document.createElement('LI');
li.innerHTML = text.replace(new RegExp('('+RegExp.escape(value)+')', 'ig'), '##$1%%').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/##([^%]+)%%/g, '<b>$1</b>');
li.onmouseover = function(){ ref.ksearch_select(this); };
li.onmouseup = function(){ ref.ksearch_click(this) };
li._rcm_id = this.env.contacts.length + i;
+ if (type) li.className = type;
ul.appendChild(li);
maxlen -= 1;
}
@@ -6076,7 +6116,10 @@ function rcube_webmail()
// 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');
}
}
};
@@ -6292,7 +6335,7 @@ function rcube_webmail()
{
// 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">')
@@ -6312,7 +6355,7 @@ function rcube_webmail()
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;
@@ -6346,12 +6389,14 @@ function rcube_webmail()
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
@@ -6647,8 +6692,9 @@ function rcube_webmail()
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(),
@@ -6656,6 +6702,13 @@ function rcube_webmail()
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;
if (top < 0)
@@ -7002,7 +7055,7 @@ function rcube_webmail()
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");
@@ -7580,20 +7633,28 @@ function rcube_webmail()
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